1

I need to show images in horizontal RecyclerView, and this RecyclerView is inside a row of RecyclerView. Now sometimes I receive 2 or 3 images and sometimes more that can fit in its width. So, i want it to be Scrollable when there are more items then its width and when it lists few items then i want empty area to be clickable as well. How can i achieve this behavior? The problem i am having is concerned in first row where the area need to be clickable is not in my control.enter image description here

Ghulam Moinul Quadir
  • 1,638
  • 1
  • 12
  • 17
Safeer
  • 1,407
  • 1
  • 25
  • 29

2 Answers2

0

I know, This is old question. But I was stumbled upon a similar scenario.

Place the recycler view inside card view (card view is actually a frame layout) and set the recycler view width to wrap_content instead of match_parent. and the card view (parent of the recycler) width to match_parent. This will give you the expected result.

The card view is required, if you want to have the elevated cards for wrapping the recycler view. Otherwise any ViewGroup (like LinearLayout,Framelayout) should work.

0

You'll need to add a custom GridlayoutManager. Check this https://gist.github.com/ArthurSav/5f80e19d9ba6d562fbd5

from Arthur's Answer

qinmiao
  • 5,559
  • 5
  • 36
  • 39