sindrenm
01/25/2023, 9:18 AMLazyVerticalGrid
? That one uses a Column
in its second item {}
to get the two items underneath each other on the right of the larger image. But I would like to avoid a Column { image, image }
, as each image
should be in its own item {}
. But I can't seem to put the third image
on the right spot, as per the second screenshot.LazyVerticalGrid(
modifier = Modifier.fillMaxSize(),
columns = GridCells.Fixed(3),
verticalArrangement = spacing,
horizontalArrangement = spacing,
contentPadding = innerPadding,
) {
item(span = { GridItemSpan(2) }) {
val url = uniqueImageUrls.firstOrNull()
ImageCell(url)
}
item {
Column(verticalArrangement = spacing) {
val second = uniqueImageUrls.getOrNull(1)
ImageCell(second)
val third = uniqueImageUrls.getOrNull(2)
ImageCell(third)
}
}
items(uniqueImageUrls.drop(3)) { imageUrl ->
ImageCell(imageUrl)
}
}
LazyVerticalGrid(
modifier = Modifier.fillMaxSize(),
columns = GridCells.Fixed(3),
verticalArrangement = spacing,
horizontalArrangement = spacing,
contentPadding = innerPadding,
) {
itemsIndexed(
items = uniqueImageUrls,
span = { index, _ ->
when (index) {
0 -> GridItemSpan(2)
else -> GridItemSpan(1)
}
},
) { _, imageUrl ->
ImageCell(imageUrl)
}
}
GridItemSpan(2)
on index 0, which will be taken up by the second item. And then the grid puts the next items after that below the large first item. But I would like it to flow next to it instead.efemoney
01/25/2023, 10:20 PMsindrenm
01/26/2023, 11:18 AM