Hey, I have a tricky problem. I need a `Pager` in ...
# compose
b
Hey, I have a tricky problem. I need a
Pager
in Compose that wraps its content (so the pager has the height of the largest child). I used Horizontal Pager from Accompanist, however since it is based on
LazyList
only the current item is measured and used for height calculation. If now the children have different heights this causes the content below the pager to jump around see video. So far my ideas: • Forcing the
LazyList
to measure/draw also items that are not visible (this is possible for RecyclerView), so far I could not find anything in the implementation source code to enable this behaviour. But maybe one of you has an idea? • Using
Row
instead of
LazyList
. I have an PoC for this, but it resulted in a lot of code since I had to implement Snapper for normal Rows and currently it is still a little bit buggy. I’m happy for every hint on this topic 🙂
plus1 2
c
What you described is pretty much expected. Pager can't wrap something which it doesn't know the height of, and a Pager could have a lot of pages in it.
b
Yeah, I totally agree. However, I have only two pages. Therefore the second idea with Row + your snapper lib, I think it is doable, just a lot of code to make it work 🙂
c
I ended up ditching LazyRow and Pager for this. So now it looks correct, but I have lost the ability to "snap", but my designer likes it better. I am working on trying to get snap behavior, but no luck to share just yet.
c
@Colton Idle @Butter.Flock how did you solve that problem? having same issue now
b
Right now, we have a workaround. We calculate the height of the content directly. The Content contains only single line texts and paddings. Hadn’t the time to search for a better solution.
c
ok, thanks. as my content is more diverse i cannot do that. 😕
c
I just used a Row with scrollable modifier
c
did you get the snapping working in the end?
c
nope