sprockets/src/main/java/net/sf/sprockets/widget/LayoutManagers.java
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;
    }
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;
    }
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.

@return 0 if the RecyclerView doesn't have a LayoutManager
Get the number of spans laid out by the RecyclerView s LayoutManager .