24

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.

Dennis Sheil
  • 729
  • 5
  • 16
haha
  • 451
  • 1
  • 4
  • 10

2 Answers2

52
  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

ankalagba
  • 94
  • 1
  • 8
Access Denied
  • 8,723
  • 4
  • 42
  • 72
2

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

Recyclerview Grid Horizontal

Nanda Z
  • 1,604
  • 4
  • 15
  • 37