private View getNextView ( RecyclerView parent ) { View firstView = parent . getChildAt ( 0 ) ; // draw the first visible child's header at the top of the view int firstPosition = parent . getChildPosition ( firstView ) ; View firstHeader = getHeaderView ( parent , firstPosition ) ; for ( int i = 0 ; i < parent . getChildCount ( ) ; i ++ ) { View child = parent . getChildAt ( i ) ; RecyclerView . LayoutParams layoutParams = ( RecyclerView . LayoutParams ) child . getLayoutParams ( ) ; if ( getOrientation ( parent ) == LinearLayoutManager . VERTICAL ) { if ( child . getTop ( ) - layoutParams . topMargin > firstHeader . getHeight ( ) ) { return child ; } } else { if ( child . getLeft ( ) - layoutParams . leftMargin > firstHeader . getWidth ( ) ) { return child ; } } } return null ; }
Returns the first item currently in the recyclerview that s not obscured by a header .