Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement horizontal gridlayoutmanager

Tags:

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

horizontal scroll diagram

        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.

like image 928
juilcho Avatar asked Nov 23 '15 03:11

juilcho


People also ask

What is span count in GridLayoutManager?

Span count refers to the number of columns. This is fairly clunky and doesn't take into account larger screen sizes or screen orientation. One approach is to create multiple layouts for the various screen sizes.


2 Answers

  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

like image 169
Access Denied Avatar answered Oct 11 '22 11:10

Access Denied


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

Recyclerview Grid Horizontal

like image 45
Nanda Z Avatar answered Oct 11 '22 11:10

Nanda Z