1

I was wondering if there was a way to allow a RecyclerView to scroll even if it does not fill the empty space. For example, in the image below, allow the grid to scroll down so cells '28' and '29' hit the bottom of the screen, leaving an empty space above 1, 2, 3 and 4. I have not been able to find anything on the topic. The RecyclerView I have implemented does not scroll unless the cells go past the bottom of the screen.

RecyclerView

Bryan
  • 14,756
  • 10
  • 70
  • 125
  • I have gotten around this by adding empty ViewHolders. – Gi0rgi0s Nov 25 '15 at 20:01
  • @Gi0rgi0s How do you know how many to put though? I don't want it to be not enough so that the screen stops scrolling in the middle, or too much so that the user can scroll most of the content off screen. – Bryan Nov 25 '15 at 20:12
  • It's tricky. If you have a fixed resolution device and you plan on implementing it on that device alone, then trial & error will get the job done. One way to do it is by measuring the screen. Another way would be to dynamically do it and check to see when the last row goes invisible. – Gi0rgi0s Nov 25 '15 at 20:38
  • You could add an additional empty ViewHolder layout that has a width equal to "match_parent" and a height equal to however many rows you would like it to scroll. Here's a link on how to make a Recyclerview with multiple ViewHolders: http://stackoverflow.com/questions/26245139/how-to-create-recyclerview-with-multiple-view-type RecyclerView can be a huge pain sometimes. – Gi0rgi0s Nov 25 '15 at 20:44
  • If you post your Adapter code, maybe we can work something out. – Gi0rgi0s Nov 25 '15 at 21:14

0 Answers0