適応型と固定型のグリッドセル
画面幅に応じてグリッドを対応させます。
「適応型と固定型のグリッドセル」はCoddyKit上の無料Jetpack Compose Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはJetpack Compose Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Jetpack Compose Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Two Ways to Size Cells
A grid needs to know how wide its columns are. Compose offers two strategies: Fixed column counts and Adaptive minimum widths. 📐
Fixed Recap
You already met GridCells.Fixed(n). It always shows n columns, so cells grow or shrink to fit the screen width.
columns = GridCells.Fixed(3)The Problem With Fixed
On a phone, 3 columns look great. On a tablet, those same 3 columns become awkwardly wide. Fixed does not adapt to bigger screens.
Enter Adaptive
With GridCells.Adaptive(minSize), you specify a minimum cell width. Compose fits as many columns as possible, then stretches them to fill.
columns = GridCells.Adaptive(minSize = 120.dp)How Adaptive Counts
Compose divides the available width by your minSize to decide the column count. A wider screen simply gets more columns, automatically.
Responsive by Default
Adaptive grids look right on phones, foldables, and tablets without any extra code. One minSize value handles every screen. 📱
Choosing a minSize
Pick a minSize that keeps content readable at its smallest. Too tiny and cells feel cramped; too large and small phones show one column.
GridCells.Adaptive(minSize = 96.dp)When Fixed Still Wins
Use Fixed when the design demands an exact count, like a 7-day calendar week that must always be 7 columns wide.
GridCells.Fixed(7)Mixing With Spacing
Both strategies pair with arrangements. The minSize in Adaptive is measured before spacing, so leave room for your gaps.
LazyVerticalGrid(
columns = GridCells.Adaptive(120.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) { }LazyHorizontalGrid Too
The same Fixed and Adaptive cells work in LazyHorizontalGrid, which scrolls sideways and fills rows top to bottom.
LazyHorizontalGrid(rows = GridCells.Adaptive(80.dp)) { }A Simple Rule
Default to Adaptive for content galleries so they scale across devices. Reserve Fixed for layouts that need a precise, meaningful column count.
Quick Check
Pick the responsive choice.
Recap: Sizing Cells
You compared Fixed exact counts with Adaptive minimum widths. Adaptive scales across devices; Fixed locks an intentional column count. 🎯
よくある質問
「適応型と固定型のグリッドセル」レッスンは無料ですか?
はい。「適応型と固定型のグリッドセル」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Jetpack Compose Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Jetpack Compose Academyコースには全4レッスンが含まれています。
「適応型と固定型のグリッドセル」で何を学びますか?
画面幅に応じてグリッドを対応させます。 ブラウザで直接実行するハンズオンコードでJetpack Compose Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Jetpack Compose Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのJetpack Compose Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「適応型と固定型のグリッドセル」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このJetpack Compose Academyレッスンでコードを書いて実行できますか?
はい。すべてのJetpack Compose Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- LazyVerticalGridギャラリー
- カルーセル用のLazyRow
- 適応型と固定型のグリッドセル
- スクロール状態とプログラムスクロール