code: 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;
      }
docs: Get the orientation of the RecyclerView's LayoutManager.
  
  @return -1 if the RecyclerView doesn't have a LayoutManager
  @see RecyclerView#VERTICAL
  @see RecyclerView#HORIZONTAL