How to implement horizontal gridlayoutmanager

故事扮演 提交于 2019-11-29 06:46:44

问题


How to implement horizontal gridlayoutmanager with recyclerview. Fixed row count. and horizontal scroll. Like this...

        gridLayoutManager = new GridLayoutManager(getContext(), 1, GridLayoutManager.HORIZONTAL, false);
    recyclerView.setLayoutManager(gridLayoutManager);
    recyclerView.setHasFixedSize(true);

I try do this. but this is not show anything in item.


回答1:


  1. Implement RecyclerAdapter, ViewHolder.
  2. Instantiate RecyclerAdapter, set its' adapter.
  3. Specify ROWSCOUNT (there are 3 rows on your picture): GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), ROWSCOUNT, GridLayoutManager.HORIZONTAL, false);

  4. Set layout manager: recyclerView.setLayoutManager(gridLayoutManager);

  5. Show your recycler view setContentView(recyclerView);

I've prepared a sample for you, check it out




回答2:


I just add the affirmation. This picture might proof that Recyclerview with GridLayoutmanager is available for horizontal.



来源:https://stackoverflow.com/questions/33863174/how-to-implement-horizontal-gridlayoutmanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!