Subfly
Subfly

Reputation: 554

how to add span size to jetpack compose LazyStaggeredGrid items

As of compose 1.3.0-beta_2, official LazyStaggeredGrid implementation has been added. However, it does not support Grid Sizes yet. For example if I want only one element in the first row and let the rest to be staggered, I can not set the span value of that first item. My question is, is there a possible workaround for now until the compose team officially add the support? Any idea is appreciated.

EDIT

For more information, you can do something like this in vertical grid:

LazyVerticalGrid(
        columns = GridCells.Fixed(2),
    ) {
        item(span = {GridItemSpan(2)}) { -> LazyStaggeredGrid does not have a parameter like this
            Box() { } -> This will fill both columns
        }
        item {
            Box() {} -> This will fill only one column
        }
    }

Upvotes: 5

Views: 1196

Answers (1)

Subfly
Subfly

Reputation: 554

As of today (25 January 2023), span has been added to LazyStaggered on JetpackCompose version 1.4.0-alpha05. You can use the "span" parameter in "item" to make it full-span or full-lane.

Upvotes: 1

Related Questions