Android Jetpack Compose LazyVerticalGrid horizontal span also adds unnecessary vertical span

Viewed 36

So, my code looks like this (I simplified it a lot for readability)

LazyVerticalGrid(
    modifier = modifier
        .background(Color.Black)
        .padding(16.dp),
    cells = GridCells.Fixed(5),
    verticalArrangement = Arrangement.spacedBy(8.dp),
    horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
    items(26) {
        Spacer(
            modifier = Modifier
                .size(64.dp)
                .background(Color.Cyan)
        )
    }
    item {
        Spacer(
            modifier = Modifier
                .height(64.dp)
                .fillMaxWidth()
                .background(Color.Magenta)
        )
    }
}

And it looks like this (screenshot from preview):

It looks like it is supposed to

However, when I add a span to the last item (the magenta one):

item(span = { GridItemSpan(2) }) {
        //The last item goes here
    }

An unwanted space in the bottom is added:

It isn't supposed to look like this

If the item with a span is the first one (before the cyan ones), the space remains in the bottom.

0 Answers
Related