Reputation: 1758
I have a recyclerview with GridLayoutManager as layout managar and what I want to achieve is like image below
As you can see every row may have multiple item just based on item width and each item is a TextView with wrap_content
width but all item have same height.
I know it is possible to set row span by SpanSizeLookup
but for doing that, I should know the count of spans before while my list rows will fill just by items width
Can anyone help me?
Upvotes: 2
Views: 4034
Reputation: 10162
You might be better off with a different Layout manager like FlexboxLayoutManager https://github.com/google/flexbox-layout
It has lots of flexibility of on controlling when the wrap the row (automatic or manual) and you can specify lots of controls on how individual cells can grow/shrink to fill a line.
There are lots of examples on the github page.
But as a starting point you could manually wrap before cells 3 and 7 to give you the 3 on the first row and 4 on the second.
Or setting FlexWrap will do it automatically based on size
Upvotes: 13