1

I have Recycler View to show my grid. My data is int[] list = {1, 2, 3, 4, 5, 6, 7}; And I use code

mRv.setLayoutManager(new GridLayoutManager(mRvIcon.getContext(), 5, GridLayoutManager.VERTICAL, false));
mRv.setAdapter(myAdapter);

and I have result:

enter image description here

But I want fill data same

enter image description here

How I can do it?

Hoa.Tran
  • 935
  • 10
  • 26
  • Are you looking for horizontal scrolling? See https://stackoverflow.com/q/33863174/1782738 – hartwecm Apr 25 '19 at 10:08
  • I think you need to modify the `LayoutManager` for this .. [Grid View version](https://stackoverflow.com/questions/5354292/possible-to-fill-a-grid-like-view-by-column-rather-than-by-row). – ADM Apr 25 '19 at 10:38

3 Answers3

0

try to add layout manager like this

new GridLayoutManager(this, 5, GridLayoutManager.HORIZONTAL, false)
Priyanka
  • 3,369
  • 1
  • 10
  • 33
0

You can use horizontal mode with 4 column:

mRv.setLayoutManager(new GridLayoutManager(mRvIcon.getContext(), 4, GridLayoutManager.HORIZONTAL, false));
mRv.setAdapter(myAdapter);
Siamak Ferdos
  • 3,181
  • 5
  • 29
  • 56
0

Thank you every one. I did it.

  mRvIcon.setLayoutManager(new GridLayoutManager(mRvIcon.getContext(), 2, GridLayoutManager.HORIZONTAL, false));

But I need custom params of item view with width = 1/5 screen width in onBinViewHolder. Thank you so much for your time!

Hoa.Tran
  • 935
  • 10
  • 26