https://kotlinlang.org logo
#compose
Title
# compose
r

Rihards

09/29/2023, 12:10 PM
Hi! Is there any way I can use
LazyVerticalGrid
so that I can have two type of column element widths?
1
Grid is not static and depends on data I receive.
r

Rebecca Franks

09/29/2023, 12:47 PM
r

Rihards

09/29/2023, 12:56 PM
Thank You, but how does it work with dynamic data? I don’t know in which places element will take up span of 2.
m

miguelsesma

09/29/2023, 1:03 PM
Try accompanist FlowRow. Perfect for that.
r

Rihards

09/29/2023, 1:07 PM
Thank You! I managed to fix the issue with example that @Rebecca Franks gave!
e

efemoney

09/29/2023, 1:07 PM
> I don’t know in which places element will take up span of 2. You kind of need to know this 🤔 Just saw your follow up comment
r

Rihards

09/29/2023, 1:11 PM
You kind of need to know this 🤔
I see that You already edited Your comment, but if I fetch data from the API where size is returned, then I can’t know that, because elements may change any time. This one works.
Copy code
items(
    elements,
    span = { element ->
        GridItemSpan(
            if (element.size == Size.SMALL) 1 else 2
        )
    }
) { element ->
    ...
}
👍 1
3 Views