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?

複数のデータを並べるときに使う関数はLazyColumnを使う

0
Posted at

LazyColumnは表すデータの数がわかっていないときに使用する。
普段、要素を縦に並べるときはColumnを使っていると思う。
ただし、スクロール前提の設計になっていないのである。
逆に、LazyColumnは並べた要素が画面よりも下に表示された場合はスマホをスワイプすることでスクロールができるのである。

LazyColumnを使うときは一つのデータをdata classで表す

使用するテキストや画像が決まっているときは、data classの引数でアノテーションを使用するとよい。
テキストを使うとき→@StringRes
画像を使うとき→@DrawableRes

複数のデータをobject型内でList形で表示したい内容を羅列する。

data classで表示する内容を決めたら、すべての要素をobject型内のListで宣言する。

まとめ

複数のデータで画面からはみ出してしまうくらいであれば、LazyColumnを使う。
data classでデータを宣言してから、object型内でListを宣言することで画面に表示することができる。

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?