0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

「Composeの基本レイアウト」のメモ#7 ~Favorite collections のグリッド - 遅延グリッドの実装~

0
Posted at

2つの固定行を持つグリッド

  • LazyHorizontalGridで作成する
    • パラメータ
      • rows, modifier

最小構成

@Composable
fun FavoriteCollectionsGrid(
    modifier: Modifier = Modifier
) {
    LazyHorizontalGrid(
        rows = GridCells.Fixed(2),
        modifier = modifier,
        
    ) {
        items(favoriteCollectionsData){ item -> 
            FavoriteCollectionCard(item.drawable, item.text)
        }
    }
}

LazyHorizontalGridの微調整

  • Gridは親要素いっぱいまで広がるため、高さを決める
    • modifier = modifier.height(168.dp)
  • グリッドの水平方向の contentPadding は 16 dp である
    • contentPadding = PaddingValues(horizontal = 16.dp)
  • 横方向と縦方向の配置は、16 dp の間隔で行われる
    • horizontalArrangement = Arrangement.spacedBy(16.dp)
    • verticalArrangement = Arrangement.spacedBy(16.dp)
  • グリッドの高さは 168 dp である
    • modifier = modifier.height(168.dp)
  • FavoriteCollectionCard の修飾子は高さ 80 dp を指定する
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?