java - Retain scroll position in infinite RecycleView inside ScrollView (ANDROID) -


i have recycleview inside scrollview can infinite scroll , load new data paging. there way save scroll position (recycleview , scrollview) when activity onpause(), , restore when onresume(). instagram, facebook, etc. when click detail posting , timeline in same position when left beforeenter code here.

my advice : use recycleview inside recycleview. recycleview can use strategy : 1) save last visible item position 2) manipulations 3) restore position

int lastviewedposition = ((linearlayoutmanager)rv.getlayoutmanager()).findlastvisibleitemposition();  //some manipulations   rv.getlayoutmanager().scrolltoposition(lastviewedposition + data.size() - 1); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -