5

I am using a NestedScrollView and I want to check if the NestedScrollView is at the bottom or at the top :-)

Any suggestions? Thank you!

FabASP
  • 471
  • 1
  • 5
  • 16

3 Answers3

1
ViewCompat.canScrollVertically(target, -1);
Bhargav Rao
  • 41,091
  • 27
  • 112
  • 129
1

Create a SetOnScrollChangeListener

BottomSheet.SetOnScrollChangeListener(this);

The inside of the listener interface

  public void OnScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY)
    {
        if (scrollY == 0)
        {
            //Do something here when ur scroll reached the bottom by scrolling up
        }

        if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight()))
        {
            //Do something here when ur scroll reached top by scrolling down
        }
    }
0

Perhaps check if computeVerticalScrollOffset() is in [0,computeVerticalScrollRange()/2]

nullpotent
  • 9,013
  • 1
  • 29
  • 41