1 year ago

#291196

test-img

nuhkoca

Strange bug with vertical arrangement in Compose

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

android

kotlin

docker-compose

grid

spacing

0 Answers

Your Answer

Accepted video resources