Can anyone help me with the issue where I was tryi...
# compose-android
r
Can anyone help me with the issue where I was trying to display the third item in the center of second row in LazyVerticalGrid but it still shows left aligned
Copy code
fun MyScreen() {
    val items = listOf("Item 1", "Item 2", "Item 3")

        LazyVerticalGrid(
            columns = GridCells.Fixed(2),
            modifier = Modifier.padding(16.dp)
        ) {
            item {
                ItemCard(items[0])
            }
            item {
                ItemCard(items[1])
            }
            item {
                Row(
                    modifier = Modifier.fillMaxWidth(),
                    horizontalArrangement = Arrangement.Center
                ) {
                    ItemCard(items[2])
                }
            }
        }
    }
d
I think you're locking yourself into 2 columns with
columns = GridCells.Fixed(2),
. Look at https://developer.android.com/jetpack/compose/lists#lazy-grids.
r
Yes want to use 2 column grid and the third item should be centered in the second row
d
In the link I posted it shows that
item
takes a
span
parameter. This should do what you want.
Copy code
item(span = {
        // LazyGridItemSpanScope:
        // maxLineSpan
        GridItemSpan(maxLineSpan)
    })