1, go directly to the top of the
Recyview.getlinearlayoutmanager (). Scrolltopositionwithoffset (0, 0);
2, slowly back to the top of the
private void Gotop (int currentpoint) {
if (currentpoint >= 0) {
int step = 3;
if (Currentpoint > 1)
Step = 10;
if (currentpoint% 5 > 1)
Step = 5;
if (Currentpoint-step > 0) {
GetView (). Getlinearlayoutmanager (). Scrolltopositionwithoffset (currentpoint-step, 0);
} else {
GetView (). Getlinearlayoutmanager (). Scrolltopositionwithoffset (0, 0);
Return
}
Message msg = Message.obtain ();
Msg.obj = Currentpoint-step;
Msg.what = What_delayed_go_top;
Gotophandler.sendmessagedelayed (msg, 30);
}
}
private static int what_delayed_go_top = 212;
/**
* Resolve memory leak issues
*/
Private final static class Gotophandler extends Handler {
Private softreference<indexforumcontentpresenter> SoftReference;
Private Gotophandler (Indexforumcontentpresenter indexfragmentpresenter) {
This.softreference = new softreference<> (indexfragmentpresenter);
}
@Override
public void Handlemessage (Message msg) {
void Duplicate Call
if (this.softReference.get () = = null)
Return
if (msg.what = = what_delayed_go_top) {//Toggle Carousel
Callback to interface to switch interface operation
This.softReference.get (). Gotop ((Integer) msg.obj);
}
}
}
2.1 Slowly back to the top:Call
int firstposition = Recyview.getlinearlayoutmanager (). Findfirstvisibleitemposition ();
Gotop (firstposition);
Android Recyview slide to the specified location