Is there a performant way to determine the height ...
# compose-android
j
Is there a performant way to determine the height of the tallest eight in a LazyRow? I would like to force all child items to use the same height (tallest) so that when horizontally scrolling you don’t see disjointed item heights.
z
If you could know anything about all items in a lazy list then it wouldn't be lazy.
☝️ 4
j
I figured that was the case. I get strange request from designers and I need to do my due diligence.
s
https://kotlinlang.slack.com/archives/C04TPPEQKEJ/p1729256636691419?thread_ts=1729235985.597359&cid=C04TPPEQKEJ This has been asked before as well. You might be able to just go with a non-lazy horizontal pager implementation by Albert there
s
FWIW, the non-lazy approach is what we've been doing.
s
Did you use a solution like Albert's here, or is there some other way to do this nowadays?
s
We just ran with a
Row(Modifier.horizontalScroll().height(IntrinsicSize.Min)
, essentially. Nothing more fancy than that.
s
So no snapping, got it 👍
s
Oh, sorry, I missed the detail about snapping.
s
I don't think it was explicitly mentioned here, but it's often what people want when they ask for "horizontal pager, but also know the max height". If anything, I was the one missing details here as OP never mentioned pagers 😅 My brain just connected some dots that were not here in the first place 😄
j
My use case doesn't need pagers so the snapping behavior isn't necessary. I believe I could get away using a Row with a horizontal scroll modifier.
👍 2
m
If you were using HorizontalPager, there's a
beyondBoundsPageCount
you can use which makes it non lazy (ish). I don't think there's any way to do this with a LazyRow or LazyColumn. HorizontalPager has it's own internal measurement policy that's passed off to the LazyLayout function that is capable of forcing you into rendering a specific amount of items up front. But again, this is all internal to HorizontalPager and you won't be able to easily use this with something else.