Refreshing data in RecyclerView and keeping its scroll position take user to the top of the activity
On item click, use call RecyclerView
's smoothScrollToPosition(0)
method.
You can see an example in this answer.
Update RecyclerView while keeping its scroll position
You can get the current position, refresh the adapter and smooth scroll to the previous position like this:
RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(context) {
@Override protected int getVerticalSnapPreference() {
return LinearSmoothScroller.SNAP_TO_START;
}
};
Then set the position to scroll to:
smoothScroller.setTargetPosition(position);
layoutManager.startSmoothScroll(smoothScroller);
Related Topics
Android Activity Ondestroy() Is Not Always Called and If Called Only Part of the Code Is Executed
Edittext: Disable Paste/Replace Menu Pop-Up on Text Selection Handler Click Event
How to Show an Activity Before My App Is Uninstalled (Android)
How to Avoid "Illegalstateexception: Scrollview Can Host Only One Direct Child"
Error Java.Lang.Classnotfoundexception: Com.Google.Android.Gms.Maps.Mapfragment in Google Map V2
Some Androids Apps Won't Connect Through Fiddler
Understanding Command Through Adb Shell and Through Code - Android
Navigation Drawer (Google+ VS. Youtube)
Difference Between Onstart() and Onresume()
Use Uri Builder in Android or Create Url with Variables
How to Create a Help Overlay Like You See in a Few Android Apps and Ics
Android Emulator Error Message: "Panic: Missing Emulator Engine Program for 'X86' Cpus."
How to Test Android Referral Tracking
Disable/Check for Mock Location (Prevent Gps Spoofing)
Android What Does the Cliptopadding Attribute Do
How to Keep Fragment Alive When Using Bottomnavigationview with New Navcontroller