2

I am building a LazyVerticalGrid and have different kind of Compose views in it. My plan is to add equal spacing between children of the grid and I already achieved this passing down Arragment.spacedBy(24.dp) to verticalArragement. However, strangely it applies the same spacing after the very last item which is not intended and expected output. From what I understand from doc, spacing is only applied in between children not after them. Am I wrong?

My sample code:

LazyVerticalGrid(
        cells = GridCells.Adaptive(146.dp),
        verticalArrangement = Arrangement.spacedBy(24.dp)
    ) {
        items(myList) {
            Image(
                url = it.cover.thumbnail,
                title = it.title,
                description = it.description,
                onClick = onWatchlistItemClick
            )
        }

        item(span = { GridItemSpan(maxCurrentLineSpan) }) {
            Divider()
        }

        item(span = { GridItemSpan(maxCurrentLineSpan) }) {
            TRText(
                text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
            )
        }
    }

Output without any spacing

enter image description here

Output with verticalArrangement

enter image description here

nuhkoca
  • 1,777
  • 4
  • 20
  • 44
  • same issue for me, did you find any solution? – Roman May 10 '22 at 16:41
  • I am facing similar issue. And while changing some code, I figured that this issue is happening when we use `GridItemSpan`. If we do not use it, this issue will not be there. – Dhaval May 25 '22 at 07:22
  • 1
    This issue is solved in compose version `1.2.0-beta02` – Dhaval May 25 '22 at 07:29
  • Thanks @Dhaval can you send me the changelog if possible? – nuhkoca May 25 '22 at 11:59
  • Well I don't find that in written anywhere but I have created 2 samples. One with compose version `1.1.1` and another with `1.2.0-beta02`. And the issue is not happening in later version. So it looks like thay have already solved it. As in version `1.1.1`, `LazyVerticalGrid` was experimental. But with new beta, it is stable. – Dhaval May 25 '22 at 13:11

0 Answers0