はじめに
今回はJetpackComposeを用いて画面いっぱいになったら自動的に折り返してくれるViewを紹介していきます
本文
com.google.accompanist
にあるflowlayout
をプロジェクトにimplemention
することで使えるようになります
//横
FlowRow(
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.Start,
maxItemsInEachRow = 4
)
maxItemsInEachRow
は名前の通り何個までを許容するかです
horizontalArrangement
は通常のArrangement
と同じで間隔や幅寄せを指定することができます。
ただし、注意が必要なのがまだBetaなのもあってFlowRow
を使う場合該当のComposable
関数に下記のアノテーションをつけなければいけません。
@OptIn(ExperimentalLayoutApi::class)
最後に
今回は非常に便利な折り返しのViewを紹介していきました
どなたかのお役に立てれば幸いです