protected int scrollInternalBy ( int dy , RecyclerView . Recycler recycler , RecyclerView . State state ) { if ( getChildCount ( ) == 0 || dy == 0 ) { return 0 ; } // indicate whether need recycle in this pass, true when scrolling, false when layout mLayoutState . mRecycle = true ; ensureLayoutStateExpose ( ) ; final int layoutDirection = dy > 0 ? LayoutState . LAYOUT_END : LayoutState . LAYOUT_START ; final int absDy = Math . abs ( dy ) ; updateLayoutStateExpose ( layoutDirection , absDy , true , state ) ; final int freeScroll = mLayoutState . mScrollingOffset ; mLayoutState . mOnRefresLayout = false ; final int consumed = freeScroll + fill ( recycler , mLayoutState , state , false ) ; if ( consumed < 0 ) { if ( DEBUG ) { Log . d ( TAG , "Don't have any more elements to scroll" ) ; } return 0 ; } final int scrolled = absDy > consumed ? layoutDirection * consumed : dy ; mOrientationHelper . offsetChildren ( - scrolled ) ; if ( DEBUG ) { Log . d ( TAG , "scroll req: " + dy + " scrolled: " + scrolled ) ; } return scrolled ; }
Handle scroll event internally cover both horizontal and vertical