How to know whether a RecyclerView / LinearLayoutManager is scrolled to top or bottom?

后端 未结 11 2082
一向
一向 2020-12-02 06:24

Currently I am using the follow code to check whether SwipeRefreshLayout should be enabled.

private void laySwipeToggle() {
    if (mRecyclerView.getChildCou         


        
11条回答
  •  眼角桃花
    2020-12-02 07:03

    Use recyclerView.canScrollVertically(int direction) to check if top or bottom of the scroll reached.

    direction = 1 for scroll down (bottom)

    direction = -1 for scroll up (top)

    if method return false that means you reached either top or bottom depends on the direction.

提交回复
热议问题