Java Code Examples for android.support.v7.widget.GridLayoutManager#setOrientation()

The following examples show how to use android.support.v7.widget.GridLayoutManager#setOrientation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseActivity.java    From Dragger with Apache License 2.0 6 votes vote down vote up
@Override protected void onPostCreate(Bundle savedInstanceState) {
  super.onPostCreate(savedInstanceState);
  String[] items = getResources().getStringArray(R.array.home);
  ArrayList<Renderable> renderables = new ArrayList<>(items.length);
  for (String text : items) {
    renderables.add(new Home(text));
  }
  observableRecyclerView.setHasFixedSize(true);
  observableRecyclerView.setItemAnimator(new DefaultItemAnimator());
  GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  observableRecyclerView.setLayoutManager(layoutManager);
  observableRecyclerView.setAdapter(
      new RendererAdapter(renderables,
          new RendererBuilder(new Factory()),
          LayoutInflater.from(this)));
}
 
Example 2
Source File: HomeLiveFragment.java    From HeroVideo-master with Apache License 2.0 6 votes vote down vote up
protected void initRecyclerView()
{

    mLiveAppIndexAdapter = new LiveAppIndexAdapter(getActivity());
    mRecyclerView.setAdapter(mLiveAppIndexAdapter);
    GridLayoutManager layout = new GridLayoutManager(getActivity(), 12);
    layout.setOrientation(LinearLayoutManager.VERTICAL);
    layout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup()
    {

        @Override
        public int getSpanSize(int position)
        {

            return mLiveAppIndexAdapter.getSpanSize(position);
        }
    });

    mRecyclerView.setLayoutManager(layout);
}
 
Example 3
Source File: SmartRecycleView.java    From AutoRecycleView with Apache License 2.0 6 votes vote down vote up
public SmartRecycleView setLayoutManger(LayoutManagerType layoutManagerType, int orientation, int spanCout) {
    RecyclerView.LayoutManager layoutManager = null;
    if (layoutManagerType == LayoutManagerType.LINEAR_LAYOUT) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        linearLayoutManager.setOrientation(orientation);
        layoutManager = linearLayoutManager;
    } else if (layoutManagerType == LayoutManagerType.GRID_LAYOUT) {
        GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, spanCout);
        gridLayoutManager.setOrientation(orientation);
        layoutManager = gridLayoutManager;
    } else if (layoutManagerType == LayoutManagerType.STAGGER_LAYOUT) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(spanCout, orientation);
        layoutManager = staggeredGridLayoutManager;
    }
    mRecyclerView.setLayoutManager(layoutManager);
    return this;
}
 
Example 4
Source File: HomeLiveFragment.java    From HeroVideo-master with Apache License 2.0 6 votes vote down vote up
protected void initRecyclerView()
{

    mLiveAppIndexAdapter = new LiveAppIndexAdapter(getActivity());
    mRecyclerView.setAdapter(mLiveAppIndexAdapter);
    GridLayoutManager layout = new GridLayoutManager(getActivity(), 12);
    layout.setOrientation(LinearLayoutManager.VERTICAL);
    layout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup()
    {

        @Override
        public int getSpanSize(int position)
        {

            return mLiveAppIndexAdapter.getSpanSize(position);
        }
    });

    mRecyclerView.setLayoutManager(layout);
}
 
Example 5
Source File: RecyclerViewUtils.java    From AndroidMVVMSample with Apache License 2.0 5 votes vote down vote up
public static void setGridManagerAndAdapter(RecyclerView recyclerView,
                                            RecyclerView.Adapter adapter, int spanCount) {
    GridLayoutManager gridLayoutManager = new GridLayoutManager(recyclerView.getContext(), spanCount);
    gridLayoutManager.setOrientation(VERTICAL);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(gridLayoutManager);
    recyclerView.setAdapter(adapter);
}
 
Example 6
Source File: EBookCategoryDetailActivity.java    From MaterialHome with Apache License 2.0 5 votes vote down vote up
@Override
protected void initEvents() {
    major = getIntent().getStringExtra("major");
    gender = getIntent().getStringExtra("gender");
    setTitle(major == null ? "category" : major);

    int spanCount = getResources().getInteger(R.integer.home_span_count);
    eBookRankPresenter = new EBookPresenterImpl(this);
    bookInfoResponses = new ArrayList<>();
    mSwipeRefreshLayout.setColorSchemeResources(R.color.recycler_color1, R.color.recycler_color2,
            R.color.recycler_color3, R.color.recycler_color4);

    //设置布局管理器
    mLayoutManager = new GridLayoutManager(this, spanCount);
    mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return mListAdapter.getItemColumnSpan(position);
        }
    });
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);

    //设置adapter
    mListAdapter = new EBookListAdapter(this, bookInfoResponses, spanCount);
    mRecyclerView.setAdapter(mListAdapter);

    //设置Item增加、移除动画
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addOnScrollListener(new RecyclerViewScrollDetector());
    mSwipeRefreshLayout.setOnRefreshListener(this);
    onRefresh();
}
 
Example 7
Source File: ViewUtil.java    From RecyclerRenderers with Apache License 2.0 5 votes vote down vote up
public static void configRecyclerView(final Context context, RecyclerView recyclerView) {
  recyclerView.setHasFixedSize(true);
  recyclerView.setItemAnimator(new DefaultItemAnimator());
  GridLayoutManager layoutManager = new GridLayoutManager(context, 2);
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  recyclerView.addItemDecoration(new MarginDecoration(context));
  recyclerView.setLayoutManager(layoutManager);
  recyclerView.setAdapter(new RendererAdapter<Console>(generateConsoles(),
      new RendererBuilder(new Factory()), LayoutInflater.from(context)));
}
 
Example 8
Source File: BookListFragment.java    From MaterialHome with Apache License 2.0 5 votes vote down vote up
@Override
protected void initEvents() {
    int spanCount = getResources().getInteger(R.integer.home_span_count);
    bookListPresenter = new BookListPresenterImpl(this);
    bookInfoResponses = new ArrayList<>();
    mSwipeRefreshLayout.setColorSchemeResources(R.color.recycler_color1, R.color.recycler_color2,
            R.color.recycler_color3, R.color.recycler_color4);

    //设置布局管理器
    mLayoutManager = new GridLayoutManager(getActivity(), spanCount);
    mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return mListAdapter.getItemColumnSpan(position);
        }
    });
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);

    //设置adapter
    mListAdapter = new BookListAdapter(getActivity(), bookInfoResponses, spanCount);
    mRecyclerView.setAdapter(mListAdapter);

    //设置Item增加、移除动画
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addOnScrollListener(new RecyclerViewScrollDetector());
    mSwipeRefreshLayout.setOnRefreshListener(this);
}
 
Example 9
Source File: DetailListActivity.java    From TVSample with Apache License 2.0 5 votes vote down vote up
private void loadDataForRecyclerViewGridLayout() {
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.ry_detail_list);
    GridLayoutManager gridlayoutManager = new AutoLayoutManager(this, 4);
    gridlayoutManager.setOrientation(GridLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(gridlayoutManager);
    recyclerView.setFocusable(false);
    mMetroViewBorderImpl.attachTo(recyclerView);
    createData(recyclerView, R.layout.detail_list_item);
}
 
Example 10
Source File: DetailListActivity.java    From TVSample with Apache License 2.0 5 votes vote down vote up
private void loadRecyclerViewMenuItem() {
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.ry_menu_item);
    GridLayoutManager layoutManager = new GridLayoutManager(this, 1);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setFocusable(false);
    mMetroViewBorderImpl.attachTo(recyclerView);
    createOptionItemData(recyclerView, R.layout.detail_menu_item);
}
 
Example 11
Source File: DemoTwoRecyclerViewActivity.java    From TvWidget with Apache License 2.0 5 votes vote down vote up
private void testRecyclerViewGridLayout() {
    //test grid
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.secondRecyclerView);
    GridLayoutManager gridlayoutManager = new TvGridLayoutManagerScrolling(this, 4);
    gridlayoutManager.setOrientation(GridLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(gridlayoutManager);
    recyclerView.setFocusable(false);


    border.attachTo(recyclerView);

    createData(recyclerView,R.layout.item);

}
 
Example 12
Source File: DemoTwoRecyclerViewActivity.java    From TvWidget with Apache License 2.0 5 votes vote down vote up
private void testRecyclerViewLinerLayout() {
    //test linearlayout
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.firstRecyclerView);
    // 创建一个线性布局管理器

    GridLayoutManager layoutManager = new GridLayoutManager(this,1);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setFocusable(false);
    border.attachTo(recyclerView);

    createData(recyclerView, R.layout.item3);

}
 
Example 13
Source File: DemoRecyclerViewActivity.java    From TvWidget with Apache License 2.0 5 votes vote down vote up
private void testRecyclerViewGridLayout() {
    //test grid
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    GridLayoutManager gridlayoutManager = new TvGridLayoutManagerScrolling(this, 4);
    gridlayoutManager.setOrientation(GridLayoutManager.HORIZONTAL);
    recyclerView.setLayoutManager(gridlayoutManager);
    recyclerView.setFocusable(false);

    border.attachTo(recyclerView);
    createData(recyclerView);

}
 
Example 14
Source File: MainActivity.java    From LivePlayback with Apache License 2.0 5 votes vote down vote up
private void loadRecyclerViewMenuItem() {
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.ry_menu_item);
    GridLayoutManager layoutManager = new GridLayoutManager(this, 1);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setFocusable(false);
    mMetroViewBorderImpl.attachTo(recyclerView);
    createOptionItemData(recyclerView, R.layout.detail_menu_item);
}
 
Example 15
Source File: BookshelfFragment.java    From ReadMark with Apache License 2.0 5 votes vote down vote up
@Override
protected void initEvents() {

    mToolbar.setTitle("Bookshelf");
    spanCount = getResources().getInteger(R.integer.gallery_span_count);
    mBookshelfPresenter = new BookshelfPresenterImpl(this);


    /*mSwipeRefreshLayout.setColorSchemeResources(R.color.recycler_color1, R.color.recycler_color2,
            R.color.recycler_color3, R.color.recycler_color4);*/

    mLayoutManager = new GridLayoutManager(getActivity(), spanCount);
    mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return mBookshelfAdapter.getItemColumnSpan(position);
        }
    });
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);

    mBookshelfs = new ArrayList<>();
    mBookshelfAdapter = new BookshelfAdapter(mBookshelfs, getActivity(), spanCount);
    mBookshelfAdapter.setOnAdjustmentConfirmListener(this);
    mBookshelfAdapter.setOnDeleteConfirmListener(this);
    mBookshelfAdapter.setOnBookshelfClickListener((BookshelfAdapter.OnBookshelfClickListener) getActivity());
    mRecyclerView.setAdapter(mBookshelfAdapter);

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    final int space = DensityUtils.dp2px(getActivity(), 4);
    mRecyclerView.addItemDecoration(new StaggeredGridDecoration(space, space, space, space, spanCount));
    onRefresh();
}
 
Example 16
Source File: Test3Fragment.java    From YCStateLayout with Apache License 2.0 5 votes vote down vote up
@Override
public void initView(View view) {
    RecyclerView recyclerView = view.findViewById(R.id.recycleView);
    GridLayoutManager layoutManager = new GridLayoutManager(activity, 2);
    layoutManager.setOrientation(OrientationHelper.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(new DividerItemDecoration(activity, DividerItemDecoration.VERTICAL));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    adapter = new RecyclerAdapter(initData());
    recyclerView.setAdapter(adapter);
}
 
Example 17
Source File: PullToZoomRecycleView.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
@Override
    public void initView(Context context, IGroupAdapter<T> adapter) {
        zoomViewEx = new PullToZoomViewEx(context, null);
        zoomViewEx.setParallax(false);
        GridLayoutManager layoutManager = new GridLayoutManager(context, 1);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        zoomViewEx.getPullRootView().setLayoutManager(layoutManager);
//        zoomViewEx.getPullRootView().setItemAnimator(new MyItemAnimator());

        zoomViewEx.getPullRootView().setAdapter((RecyclerView.Adapter) adapter);
    }
 
Example 18
Source File: DappFragment.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void initViews(Bundle savedInstanceState) {
    //系统刷新
    mSpring.setHeader(new AppDefeatHeadView(getContext()));
    mSpring.setGive(SpringView.Give.BOTH);
    mSpring.setType(SpringView.Type.FOLLOW);
    mSpring.setListener(new SpringView.OnFreshListener() {
        @Override
        public void onRefresh() {
            mBussinessDappList.clear();
            mHeaderList.clear();
            ivLsit.clear();
            presenter.getData(); // 获取服务器数据
        }

        @Override
        public void onLoadmore() {
            mSpring.onFinishFreshAndLoad();
        }
    });
    GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 4);
    layoutManager.setOrientation(GridLayoutManager.VERTICAL);
    layoutManager.setSmoothScrollbarEnabled(true);
    mRecycleApplication.setLayoutManager(layoutManager);
    mHeaderAdapter = AdapterManger.getDappHeadAdapter(getActivity(), mHeaderList);
    mRecycleApplication.setAdapter(mHeaderAdapter);

    GridLayoutManager layoutManager1 = new GridLayoutManager(getActivity(), 2);
    layoutManager1.setOrientation(GridLayoutManager.VERTICAL);
    layoutManager1.setSmoothScrollbarEnabled(true);
    if (Utils.getSpUtils().getString("loginmode").equals("phone")) {
        mRecycleBussinessApplication.addItemDecoration(new RecycleViewDivider(getContext(), LinearLayoutManager.HORIZONTAL, 1, getResources().getColor(R.color.line)));
        mRecycleBussinessApplication.addItemDecoration(new RecycleViewDivider(getContext(), LinearLayoutManager.VERTICAL, 1, getResources().getColor(R.color.line)));
    } else {
        mRecycleBussinessApplication.addItemDecoration(new RecycleViewDivider(getContext(), LinearLayoutManager.HORIZONTAL, 1, getResources().getColor(R.color.blackbox_line)));
        mRecycleBussinessApplication.addItemDecoration(new RecycleViewDivider(getContext(), LinearLayoutManager.VERTICAL, 1, getResources().getColor(R.color.blackbox_line)));
    }
    mRecycleBussinessApplication.setLayoutManager(layoutManager1);
    mBussinessDappAdapter = new EmptyWrapper(AdapterManger.getDappBussnessAdapter(getActivity(), mBussinessDappList));
    mBussinessDappAdapter.setEmptyView(R.layout.empty_project);
    mRecycleBussinessApplication.setAdapter(mBussinessDappAdapter);
}
 
Example 19
Source File: AlbumsFragment.java    From MultiImagePicker with MIT License 3 votes vote down vote up
protected void setupRecycler() {

        mAlbumsRecycler.setHasFixedSize(true);
        final GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), getResources().getInteger(R.integer.num_columns_albums));
        gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);

        mAlbumsRecycler.setLayoutManager(gridLayoutManager);


    }
 
Example 20
Source File: ImagesThumbnailFragment.java    From MultiImagePicker with MIT License 3 votes vote down vote up
protected void setupRecycler() {

        mImagesRecycler.setHasFixedSize(true);
        final GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), getResources().getInteger(R.integer.num_columns_images));

        gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);

        mImagesRecycler.setLayoutManager(gridLayoutManager);
        mImagesRecycler.addItemDecoration(new SpacesItemDecoration(getResources().getDimensionPixelSize(R.dimen.image_spacing)));


    }