LazyColumn's scroll position resets on system-initiated process death
Opened this issue · 1 comments
nicolarevelant commented
This article explains why it matters: Save UI State - Android Developers
Problem: when I perform this sequence of events the LazyColumn's scroll position resets:
- From homepage, swipe up
- background/foreground app with "Don't Keep Activities" option enabled
or:
- From a community page, swipe up
- background/foreground app with "Don't Keep Activities" option enabled
Possible solution:
save the posts list using SavedStateHandle and declare the postListState using rememberLazyListState() in a Composable instead of using a ViewModel
Screenshots:
Version:
0.0.66 - not fixed in 0.0.75
MV-GH commented
declare the postListState using rememberLazyListState() in a Composable instead of using a ViewModel
Not possible, it used to be like this. But if you switch between home and any other tab (inbox/profile...). You will lose the position.
Thats why HomeViewmodel doesn't follow the lifecycle of HomeScreen and why it keeps the state.