The code has been sorted out, see below ~ one day you will use the ~ welcome ha ~650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0057.gif "alt=" j_0057.gif "/ >
Monitor Recyclerview scrolling Status Mrecyclerview.addonscrolllistener (New recyclerview.onscrolllistener () { @Override public void onscrollstatechanged (recyclerview recyclerview, int newstate) { Super.onscrollstatechanged (recyclerview, newstate); if ( Recyclerview.getlayoutmanager () != null) { getpositionandoffset (); } });/** * record Recyclerview current position */private void getpositionandoffset () { LinearLayoutManager layoutManager = (Linearlayoutmanager) Mrecyclerview.getlayoutmanager (); //gets the first visual view view Topview = layoutmanager.getchildat (0); &nbsP; if (topview != null) { // Gets the offset from the top of the View lastoffset = topview.gettop (); //gets the array position of the view Lastposition = layoutmanager.getposition (TopView); }}/** * Let Recyclerview scroll to the specified position */private void scrolltoposition () { if ( Mrecyclerview.getlayoutmanager () != null && lastposition >= 0) { ((Linearlayoutmanager) mrecyclerview.getlayoutmanager ()). Scrolltopositionwithoffset (lastposition, lastoffset); }}
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/8D/BC/wKiom1iofFPScKJEAAQ8zhtm9UY253.gif "title=" C2adb464tw1etn3dny1qng208c04p7bj.gif "alt=" Wkiom1ioffpsckjeaaq8zhtm9uy253.gif "/>
This article is from the "Liangxiao Technology Center" blog, please be sure to keep this source http://liangxiao.blog.51cto.com/3626612/1899155
Android Studio Phase 31st-record Recyclerview scrolling position and restore