Android:检查NestedScrollView是在底部还是在顶部

时间:2015-08-29 16:07:07

标签: android nestedscrollview

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

有什么建议吗? 谢谢!

3 个答案:

答案 0 :(得分:1)

ViewCompat.canScrollVertically(target, -1);

答案 1 :(得分:0)

答案 2 :(得分:0)

创建一个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
        }
    }