Recycle滑动监听

recycleView可以通过addOnScrollListener()添加一个监听滚动

 public abstract static class OnScrollListener {
       //当recycleView的滑动状态改变时回调
        public void onScrollStateChanged(RecyclerView recyclerView, int newState){}

      //滚动的时候回调
        public void onScrolled(RecyclerView recyclerView, int dx, int dy){}
    }

onScrollStateChanged newState滚动的状态

/**
 * The RecyclerView is not currently scrolling.
 * 当前的recycleView不滑动(滑动已经停止时)
 */
public static final int SCROLL_STATE_IDLE = 0;

/**
 * The RecyclerView is currently being dragged by outside input such as user touch input.
 * 当前的recycleView被拖动滑动
 */
public static final int SCROLL_STATE_DRAGGING = 1;

/**
 * The RecyclerView is currently animating to a final position while not under
 * outside control.
 * 当前的recycleView在滚动到某个位置的动画过程,但没有被触摸滚动.调用 scrollToPosition(int) 应该会触发这个状态
 */
public static final int SCROLL_STATE_SETTLING = 2;

你可能感兴趣的:(Recycle滑动监听)