0
0

More than 1 year has passed since last update.

jetpack composeで折り返しのViewを作る

Posted at

はじめに

今回は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を紹介していきました
どなたかのお役に立てれば幸いです

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