Reputation: 158
I want to change LayoutManger
(I don't know what that is called in jetpack compose) for LazyColumn
so I can make the items scroll horizontally or vertically or in grid.
Upvotes: 0
Views: 2684
Reputation: 364441
With 1.0.0
you can use:
LazyColumn
: produces a vertically scrolling listLazyRow
: produces a horizontally scrolling listSomething like:
LazyColumn {
items((1..1000).toList()) {
Text(text = "Item $it")
}
}
LazyVerticalGrid
provides experimental support for displaying items in a grid.Something like:
val numbers = (0..20).toList()
LazyVerticalGrid(
cells = GridCells.Fixed(4)
) {
items(numbers) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text(text = "Number")
Text(text = " $it",)
}
}
}
Upvotes: 4
Reputation: 1574
In Jetpack Compose you can use LazyRow
for horizontal scroll. LazyVerticalGrid
can be used for Grid
, which is still an experimental API. Read more here.
This for complete details about lists.
Official Jetpack Compose samples
Upvotes: 2