I have a `LazyColumn` and I want it to retain scro...
# compose
o
I have a
LazyColumn
and I want it to retain scroll position relative to the item key when I update the content. E.g. if I have items from the
listOf(1,2,3)
and I scroll to top, and then update data and repopulate items from
listOf(0,1,2,3)
I want scroll position to be still at item
1
with the same offset, and to see item
0
user would need to scroll up. Any hints on how to implement this effectively?
1
m
Interesting, I had that behavior by default, and had to figure out how to stop it from happening because I wanted it to be at 0 after the items change, but it stayed at 1.
z
I think that happens automatically if you specify keys for your items? I might be wrong 🤔
1
☝️ 1
o
I did specify the keys, yes. Will need to investigate further…
👍🏽 1
Got it, I had “virtual” item at the top which would display “loading…” and it didn’t have a key, and it was always first, so it scrolled to it. Redesigned the component to have only real items in the list, and it all works
🦜 1