6

我正在使用 NestedScrollView,我想检查 NestedScrollView 是在底部还是在顶部:-)

有什么建议么?谢谢!

4

3 回答 3

1

创建一个 SetOnScrollChangeListener

BottomSheet.SetOnScrollChangeListener(this);

监听器接口内部

  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
        }
    }
于 2017-02-21T15:18:01.157 回答
1
ViewCompat.canScrollVertically(target, -1);
于 2016-09-20T15:47:44.873 回答
0

也许检查computeVerticalScrollOffset()是否在 [0, computeVerticalScrollRange()/2 ]

于 2015-08-29T16:38:24.733 回答