public static int getSpanCount ( RecyclerView view ) { LayoutManager layout = view . getLayoutManager ( ) ; if ( layout != null ) { if ( layout instanceof GridLayoutManager ) { return ( ( GridLayoutManager ) layout ) . getSpanCount ( ) ; } else if ( layout instanceof StaggeredGridLayoutManager ) { return ( ( StaggeredGridLayoutManager ) layout ) . getSpanCount ( ) ; } return 1 ; // assuming LinearLayoutManager } return 0 ; }
Get the number of spans laid out by the RecyclerView s LayoutManager .