Hi, how can i get LazyColumn scroll percentage ?
# compose
y
Hi, how can i get LazyColumn scroll percentage ?
j
you have
firstVisibleItemIndex
that you can calculate de percentage with this information. Ex.: List with 10 items, the first visible is the third item, so your scroll percentage is 30%
1
f
Just be aware that this will be "item scroll" percentage and not really a "content scroll" percentage. For the latter you would have to calculate height of all the items which would defeat the purpose of lazy layout 😕 Also I think that by using this method you would never get a 100% scroll, right? 🤔
n
"what about mixing with lastVisibleItemIndex" but it doesn't exists 😄
j
Agree. Maybe will not be exactly what you want, maybe you have to calculate height, like @Filip Wiesner said.
n
you can use
layoutInfo.visibleItemsInfo
to get all the visible items displayed on screen, maybe it can help to extrapolate an approximate scroll position, because I also don't think you should break the lazylist principle
f
Yeah, I didn't mean it like you should measure your items. I was just pointing out that Jhonatans answer may not be what you are looking for. I don't think there is a solution for this. All you can do is approximate the scroll position like nitrog42 suggests.
1