How to implement horizontal gridlayoutmanager
Asked Answered
F

2

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.

Fane answered 23/11, 2015 at 3:8 Comment(0)
B
54
  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

Bourgeon answered 24/11, 2015 at 7:2 Comment(2)
What if fill rows first ? Is there a way for this ?Kaiulani
@Kaiulani Ask a new question, didn't quite get what you need.Bourgeon
D
2

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

Recyclerview Grid Horizontal

Darindaring answered 18/9, 2019 at 11:22 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.