0Pricing
Jetpack Compose Academy · レッスン

LazyVerticalGridギャラリー

スクロール可能なグリッドに項目を配置します。

「LazyVerticalGridギャラリー」はCoddyKit上の無料Jetpack Compose Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはJetpack Compose Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Jetpack Compose Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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. ✨

よくある質問

「LazyVerticalGridギャラリー」レッスンは無料ですか?

はい。「LazyVerticalGridギャラリー」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Jetpack Compose Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Jetpack Compose Academyコースには全4レッスンが含まれています。

「LazyVerticalGridギャラリー」で何を学びますか?

スクロール可能なグリッドに項目を配置します。 ブラウザで直接実行するハンズオンコードでJetpack Compose Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Jetpack Compose Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのJetpack Compose Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「LazyVerticalGridギャラリー」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このJetpack Compose Academyレッスンでコードを書いて実行できますか?

はい。すべてのJetpack Compose Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. LazyVerticalGridギャラリー
  2. カルーセル用のLazyRow
  3. 適応型と固定型のグリッドセル
  4. スクロール状態とプログラムスクロール
← Jetpack Compose Academyに戻る