Open
Description
how-to-put-a-lazyverticalgrid-inside-a-scrollable-column when item count = 500, maybe have some problems in scroll
@Preview(showBackground = true)
@Composable
private fun Test() {
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
) {
Box(modifier = Modifier
.fillMaxWidth()
.height(200.dp)
.background(Color.Red))
Stats(
modifier = Modifier.heightIn(max = 1000.dp),
stats = List(500) { it }
)
Box(modifier = Modifier
.fillMaxWidth()
.height(200.dp)
.background(Color.Yellow))
}
}
@Composable
fun Stats(
modifier: Modifier = Modifier,
stats: List<Int>
) {
LazyVerticalGrid(
modifier = modifier,
columns = GridCells.Fixed(2)
) {
itemsIndexed(stats) { index, item ->
Box(
modifier = Modifier.aspectRatio(1f),
contentAlignment = Alignment.Center
) {
Text("Item $index")
}
}
}
}
Metadata
Metadata
Assignees
Labels
No labels