Can I somehow access the total scroll amount from ...
# compose-android
m
Can I somehow access the total scroll amount from a
LazyListState
? I have a view drawn on top of a
LazyRow
and I want to move it with the list scroll. Or maybe there is a better/alternative way to do it?
z
Knowing the total scroll amount would require knowing the total size of the content, which would defeat the purpose of lazy lists.
m
Isn't there some sort of a delta dispatch that could be accumulated?
z
Yes, if you know that the items won’t change size or be added/removed prior to the current position
m
So I'll need to write my own lazy scrollable composable for that, correct?
z
I think so? I don’t think you can just wrap LazyListState because you could miss windows if the scroll is happening too fast
If your items are all the same size, then you could calculate it just from the
firstItemIndex
a
What’s the usage of the
LazyRow
in this case? Are there going to be elements other than the tick marks that you’re scrolling through?
m
There are only tick marks but I'm also supporting zoom gesture for empty spaces with
transformable()
modifier so both item count and item width change.
a
Got it, so each tick mark or group of tick marks is a different item?
m
Yes, they are timestamps in an audio file. Initially they are shown for every 5 seconds of an audio file and then users can use zoom gesture to increase or decrease the resolution.
a
You might be able to avoid a
Lazy
container entirely, and have a component that is scrollable, zoomable, and manually draws the tick marks in that area based on the combination of scroll position and zoom - and then the overlay can be drawn based on the same information. That might be a bit more setup, but you can avoid fighting with the
LazyListState
that way
m
I was thinking that as well. I started playing with today so
LazyRow
was my first idea for an implementation but it seems like I'm going against the grain so far. In any case thank you both!
109 Views