-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve scroll position on Android Activity restoration #1494
Conversation
this PR right now is pending on |
The idea we were discussing is summarised in #1384. We can either go that route of making arbitrary content serializable, or we can just add serialization support for non- |
7179f2e
to
c197418
Compare
I tested this change locally, with the change for view id, now scroll position is saved!! ✨ |
d6a566f
to
a987712
Compare
@jingwei99 Did you test this with the Activity screen, or one of the sample apps? I'm just asking because I tried testing it on Emoji Search and it isn't working |
I was testing it on the sample app, and it worked. 🤔 maybe I didn't have the |
Superseded by #1599 |
This doesn't work yet, as
rememberSaveable
needs to support saving of values that aren'tMutableState
's. Currently, when trying to save the state, we get the following error:One trade-off here is that we're just saving the first visible item index, and thus we only restore the first visible item index when we come back. What this means is that if we scroll past 4 items, and the top of the
LazyList
has scrolled half of the fifth item, when we restore the scroll position, we will show the whole of the fifth item instead of half of it. I think this is perfectly okay for now, as the gains we get from restoring the scroll index is ginormous.