Build Layouts with Jetpack Compose

Sep 10 2024 · Kotlin 1.9, Android 14, Android Studio Iguana | 2023.2

Lesson 03: Work with Grids

Demo

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Open the Starter project in the 03-work-with-grids directory of the m3-ljp-materials repo in Android Studio Hedgehog or later.

LazyVerticalGrid(
    columns = GridCells.Adaptive(80.dp),
    modifier = Modifier.fillMaxSize(),
    horizontalArrangement = Arrangement.spacedBy(4.dp),
    verticalArrangement = Arrangement.spacedBy(4.dp)
) {

}
items(state) { photo ->
    PhotoItem(photo)
}
LazyVerticalStaggeredGrid(
    modifier = Modifier.fillMaxSize(),
    columns = StaggeredGridCells.Adaptive(80.dp),
    verticalItemSpacing = 12.dp,
    horizontalArrangement = Arrangement.spacedBy(8.dp),
    content = {
        items(state) { photo ->
            PhotoItem(photo)
        }
    }
)
See forum comments
Cinema mode Download course materials from Github
Previous: Instruction Next: Conclusion