Hi! Is there any way I can use `IntrinsicSize.Max`...
# compose-android
r
Hi! Is there any way I can use
IntrinsicSize.Max
with
HorizontalPager
? I need to set the same height for all elements inside the pager because the text length is different for each. An alternative could be to use Row with a specific fling behaviour to achieve the same scroll behaviour, but not sure how to do that.
s
Pager is a lazy layout, so by definition it won't know how to match the biggest item's height without having to measure all of them. But it does not measure all of them since it's lazy. Read this thread https://kotlinlang.slack.com/archives/CJLTWPH7S/p1689853498334149?thread_ts=1689848336.886339&cid=CJLTWPH7S for more context
r
Thank You, I will take a look! I’m aware of it being lazy, but wanted to know if there is an actual way to resolve this 🫠
s
Yeah, but not being lazy is a real way to solve this 😄 Or by animating the height constraints when new items are measured and they are bigger than what you had before. Those are the two options afaik
gratitude thank you 1
c
I think i did this a while back two different ways: 1. accompanist horizontal pager originally was non-lazy. so you can go back and copy that code if you want 😄 2. Row can be set to scrollable and you can give it a fling behavior as of like last year (i forget the exact api name). So basically you recreate a horizontalPager with just a Row, and so if you know you only have like 5 items then you know you won't kill your perf or anything.
gratitude thank you 1