public static int getOrientation(RecyclerView view) {
        LayoutManager layout = view.getLayoutManager();
        if (layout instanceof LinearLayoutManager) {
            return ((LinearLayoutManager) layout).getOrientation();
        } else if (layout instanceof StaggeredGridLayoutManager) {
            return ((StaggeredGridLayoutManager) layout).getOrientation();
        }
        return -1;
    }
public static int getOrientation(RecyclerView view) {
        LayoutManager layout = view.getLayoutManager();
        if (layout instanceof LinearLayoutManager) {
            return ((LinearLayoutManager) layout).getOrientation();
        } else if (layout instanceof StaggeredGridLayoutManager) {
            return ((StaggeredGridLayoutManager) layout).getOrientation();
        }
        return -1;
    }
public static int getOrientation ( RecyclerView view ) { LayoutManager layout = view . getLayoutManager ( ) ; if ( layout instanceof LinearLayoutManager ) { return ( ( LinearLayoutManager ) layout ) . getOrientation ( ) ; } else if ( layout instanceof StaggeredGridLayoutManager ) { return ( ( StaggeredGridLayoutManager ) layout ) . getOrientation ( ) ; } return - 1 ; }
Get the orientation of the RecyclerView's LayoutManager.

@return -1 if the RecyclerView doesn't have a LayoutManager
@see RecyclerView#VERTICAL
@see RecyclerView#HORIZONTAL
Get the orientation of the RecyclerView s LayoutManager .