How can I separate items in a LazyVerticalGrid wit...
# compose
f
How can I separate items in a LazyVerticalGrid with Dividers? Adding a horizontal line between each row is easy but I don't know how to separate the columns with vertical lines. Using a Box with a border doesn't work well because the start/end borders add up.
1
a
Cut the border size in half so it adds up correctly, or just render it correctly based on the column index
c
Just always show a border bottom and border right except for the last column and the last row?
c
If the columns are fixed (not adaptive), you could use a vertical Divider:
Divider(Modifier.width(1.dp).fillMaxHeight())
f
the grid is adaptive tho 😕
and I guess I can't know when an item is the last in a row
a
there is
LazyListScope.itemsIndexed
f
@allan.conda bu I still don't kow how many items are displayed per row, right?
a
Ah… Right, since it’s Adaptive.
To be honest that LazyGrid api kinda sucks 😅 and not flexible, though it’s still experimental to be fair. I think you can workaround by copying how they compute the columns for Adaptive
Copy code
BoxWithConstraints(
  modifier = modifier
) {
  val nColumns = maxOf((maxWidth / cells.minSize).toInt(), 1)
👍 1
c
@Andrey Kulikov might have some thoughts
a
cc @Mihai Popa