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?

JetpackComposeでFlexboxみたいなUIを作る

Posted at

JetpackComposeでFlexboxみたいなUIの作成方法です。

Flowレイアウトについてはこちらを参照

FlowRowにViewを入れていくと自動的に折り返します。

FlowRowSample.kt
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun FlowRowSample() {
    val items = listOf("Arctic Fox", "Bumblebee", "Chipmunk", "Dolphin","Electric Eel", "Flamingo", "Hedgehog", "Koala", "Meerkat")

    Box(
        modifier = Modifier.fillMaxSize(),
        contentAlignment = Alignment.Center
    ) {
        FlowRow(
            horizontalArrangement = Arrangement.Center
        ) {
            items.forEach {
                AssistChip(
                    onClick = {},
                    label = { Text(it) }
                )
            }
        }
    }
}

実行結果

Screenshot_20250504_121305.png

簡単に実装できそうですね。

以上になります。

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?