I have 2 Fragments A and B.
A contains a ScrollView, if I scroll down and press a button Fragment A gets replaced by Fragment B. Now i press the back-button and Fragment A comes back to the screen, but the ScrollView is not at the same position as it was when I switched to Fragment B.
But when I do the same with a Fragment (not a ListFragment!) that contains a ListView the scroll position is maintained.
Is there anything special I have to do with my ScrollView?!
Greetings, Daniel.
Both ScrollView and NestedSrollView has inner class extended from BaseSavedState which saves state of scrollPosition. You merely need to give your scrolling view an id to save and restore it's instance state automatically (you do NOT need to call it manually).. See Could I keep position of ScrollView after back to prev Fragment like ListView?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With