0Pricing
Jetpack Compose Academy · Lesson

LazyVerticalGrid Galleries

Arrange items in a scrollable grid.

LazyVerticalGrid Galleries is a free Jetpack Compose Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Jetpack Compose Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Grids in Compose

When a screen full of photos needs neat rows and columns, you reach for LazyVerticalGrid. It scrolls vertically and only composes the cells you can see. 🖼️

Why Lazy?

Like LazyColumn, a lazy grid skips off-screen items. A thousand-image gallery stays smooth because Compose builds cells on demand, not all at once.

The Basic Setup

You give LazyVerticalGrid a column count and feed it items. Each item becomes one cell, and Compose flows them left to right, then down.

LazyVerticalGrid(columns = GridCells.Fixed(2)) {
    items(photos) { photo ->
        PhotoCell(photo)
    }
}

GridCells.Fixed

Use GridCells.Fixed(n) when you want an exact column count, like a tidy 3-across icon grid that never changes.

columns = GridCells.Fixed(3)

Spacing Between Cells

Add breathing room with Arrangement parameters. They control the gap between rows and the gap between columns separately.

LazyVerticalGrid(
    columns = GridCells.Fixed(2),
    verticalArrangement = Arrangement.spacedBy(8.dp),
    horizontalArrangement = Arrangement.spacedBy(8.dp)
) { }

Padding Around the Grid

Use contentPadding to inset the whole grid from the screen edges. It keeps the first and last cells from hugging the borders.

contentPadding = PaddingValues(16.dp)

Items From a List

The items builder takes your data list and a cell lambda. Each element of the list maps to exactly one composed cell.

items(galleryPhotos) { photo ->
    AsyncImage(model = photo.url, contentDescription = null)
}

A Single Special Cell

Need a header or a one-off cell? Use item (singular) for content that should not repeat over your list.

item { GalleryTitle() }
items(photos) { PhotoCell(it) }

Spanning Across Columns

A cell can stretch across the whole row with a span. This is perfect for a section title sitting above its photos.

item(span = { GridItemSpan(maxLineSpan) }) {
    SectionHeader("Recent")
}

Keep Cells Square

Photo galleries look best when cells are square. Apply aspectRatio(1f) to each cell so height tracks its width.

Box(Modifier.aspectRatio(1f)) { PhotoCell(photo) }

Grid vs List

Choose a grid when items are visual and equally weighted, like thumbnails. Choose a list when each row is a distinct, full-width record.

Quick Check

A quick one on column counts.

Recap: Grid Galleries

You met LazyVerticalGrid: lazy cells, a column count, spacing, padding, and spans. It is your go-to for scrollable photo galleries. ✨

Frequently asked questions

Is the “LazyVerticalGrid Galleries” lesson free?

Yes — the full text of “LazyVerticalGrid Galleries” is free to read here on the web, and the Jetpack Compose Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Jetpack Compose Academy course, upgrade to CoddyKit PRO.

What will I learn in “LazyVerticalGrid Galleries”?

Arrange items in a scrollable grid. You practise Jetpack Compose Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Jetpack Compose Academy?

No prior experience is required. Jetpack Compose Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “LazyVerticalGrid Galleries” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Jetpack Compose Academy lesson?

Yes. Every Jetpack Compose Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. LazyVerticalGrid Galleries
  2. LazyRow for Carousels
  3. Adaptive vs Fixed Grid Cells
  4. Scroll State & Programmatic Scrolling
← Back to Jetpack Compose Academy