I also came across a similar kind of script. In my case, when I scroll down to the end, the FAB button should appear, and when the user clicks on this FAB button, it goes to the top of the page. For this, I added @SilentKnight answer NestedScrollView.scrollTo(0, 0); To go up, but this is not enough for smooth animation to scroll up.
For smooth animation, I used @Sharj's answer, which is NestedScrollView.fullScroll(View.FOCUS_UP); But then my AppBar is not visible there, so I need to extend the AppBar as follows appBarLayout1.setExpanded(true) . Thus, using these three, I can smoothly jump to the top of the page.
nestedScrollView.fullScroll(View.FOCUS_UP); nestedScrollView.scrollTo(0,0); appBarLayout1.setExpanded(true);
Vidu Mar 23 '18 at 5:30 2018-03-23 ββ05:30
source share