In a `LazyVerticalGrid` where the items are `2 x N...
# compose
l
In a
LazyVerticalGrid
where the items are
2 x N
, is it possible for a given row to set both items to the max height of either row? My use case is that I have a tile where a title can wrap 1 or 2 rows. But I like the bottom divider and user image to be aligned at the bottom of the tile. I can’t set a fixed height because if both tiles have a title of 1 line or both have 2 lines, no adjustment is needed. Only when the left tile and right tile have a different number of lines, I would like to add a spacer or some way to push the divider + user image/details to the bottom
I think that if I’m able to set the height to the max height of the tallest cell, a spacer with a weight could help me here
c
The tricky part though is what cell really represents the tallest? The lazy nature means you may have items that have yet to be loaded so do you mean tallest rendered cell in the viewport? I also wonder if basing height off of that can make scrolling look odd because every row may change height as you scroll
o
From Compose 1.4.0-alpha02 we are now able to define
minLines
for
BasicText
. If you set minLines = 2 for the title it should do the trick. https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.4.0-alpha02
e
No more alpha, Compose 1.4 is in RC 🙂
l
Chris: yeah, I kinda figured that you would need a initial pass to figure out the final height (in my use case the data is already readily available) but it can mean that each row can have a different height depending on the cell’s content. Oleksandr: But that would put whitespace between “CookieMonster” and “Upcoming Auction” on the left tile if i understand correctly? Ideally i would have additional whitespace on the left tile between “Starting at $0” and the grey divider
o
Whitespace between “CookieMonster” and “Upcoming Auction”
Yeap, and both “Upcoming Auction” and “Staringat $0" will be aligned on left and right tiles
between “Starting at $0” and the grey divider
I guess you will need a custom layout then 🤔