Jul 30, 2017 · 1 min read
The way I’d approach this situation is if the View (Activity/Fragment) is destroyed because that’s how the “navigation components” handles its lifecycle then I’d not store scroll positions or any other UI variables.
You’ll need more code to handle restoration/save of those values from SharedPreferences or even a DB. That’s what I meant with the “don’t fight the system”. You have methods like onSaveInstanceState() and onRestoreInstanceState() where you can save and restore scroll positions.
So I’d say to let the UI related methods and lifecycle handle UI related data. You can try and check alternatives for “top components” (BottomNavigation, TabNavigation, etc…) and see what’s expected UI wise from those components.
