Skip to content Skip to sidebar Skip to footer

Prevent Nestedscrollview Scrolls To Top Automatically

I have ListView inside NestedScrollView (do not want use RecycleListView) in my fragment. List adapter inits in onCreate and not recreated when app back to the fragment from other

Solution 1:

You should retain the list status in onPause() method on the Fragment (save it to the Bundle) and then read and set it in onResume(). Just create some constant key, save then read :-)

The value you will want to save is getScrollY() most probably. Then you will want to restore it with scrollTo(int x, int y) where x=0 and y=savedValue.

Also, you do want to use RecyclerView :-) It is really cool and works really well with NestedScrollView and CoordinatorLayout. Also, it is much easier and quicker to implement than ListView once you get the hang of it. It is also very lightweight. And I had once seen it save a puppy from a fire. RecyclerView is da man! :-D

Solution 2:

Remove @string/appbar_scrolling_view_behavior form the NestedScrollView layout.

Post a Comment for "Prevent Nestedscrollview Scrolls To Top Automatically"