Programmatically scroll to the top of a NestedScrollView

后端 未结 13 1649
情书的邮戳
情书的邮戳 2020-12-13 12:02

Is there a way to programmatically scroll to the top of a NestedScrollView by also triggering the scroll events for the parent? smoothScrollTo(x, y)

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 12:31

    You can use this for smooth scroll.

    nestedScrollView.fullScroll(View.FOCUS_UP);
    nestedScrollView.smoothScrollTo(0,0);
    

    OR for normal scroll

    nestedScrollView.fullScroll(View.FOCUS_UP);
    nestedScrollView.scrollTo(0,0);
    

提交回复
热议问题