Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@droid-it
Created September 26, 2022 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save droid-it/36a5978cdce999ac55b5d005670ce011 to your computer and use it in GitHub Desktop.
Save droid-it/36a5978cdce999ac55b5d005670ce011 to your computer and use it in GitHub Desktop.
@Composable
fun AdaptiveLazyGrid() {
val colors = remember {
listOf(Color.Yellow, Color.LightGray, Color.Cyan)
}
LazyVerticalGrid(
columns = GridCells.Adaptive(120.dp),
content = {
for (i in 0..20) {
item {
Box(
modifier = Modifier
.width(100.dp)
.height(60.dp)
.background(colors[i % 3])
) {
Text("Item $i", modifier = Modifier.padding(4.dp))
}
}
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment