2

I have a recyclerview within a recyclerview. The inner one is linear and the outer one is a staggered grid layout. As seen in the picture, MARKET was the last word added, and it is offscreen and therefore the user needs to scroll to use it. However, the layout manager should've swapped the word BIT with MARKET and they would all have room on the screen. Nested RecyclerView - Image 1

The layout initialization:

   staggeredGridLayout= new StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.HORIZONTAL);

I am controlling the spacing between the words with this code in the outer recyclerview adapter:

holder.itemView.getLayoutParams().width=holder.mList.size()*100+(holder.mList.size()-1)*20+100;

[For now the numbers are absolute, later on I will change them according to screen width]

Any idea how I can control the whole thing to fit? Note, the screen size as it is can hold all the letters available (example with 3 letter words).

Ignore the made up words - Image 2

I tried using GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS but that didn't help although I have gaps. Can I override the strategy and change it?

Another option- Is there a method that plays around and redraws/ relays the views?

Thank you!

Sharone Lev
  • 791
  • 7
  • 15

0 Answers0