SpannedGridLayoutManager icon indicating copy to clipboard operation
SpannedGridLayoutManager copied to clipboard

Is there a way to force line height ?

Open prouland opened this issue 7 years ago • 3 comments

Hello here.

I tried to force the line height in the case of a vertical spanned grid recycler view. On creating the ViewHolder, I set a new SpanLayoutParams with a computed height (here we try to have a specific number of line matching the recycler height).

But items are drawn with a height matching the width of a one-span-sized item.

Is there a way to achieve this with this SpannedGridLayoutManager ?

Thanks by advance.

Edit: just to know, the same methos of forcing items line height works fine with a classic GridLayoutManager.

prouland avatar Apr 12 '18 13:04 prouland

Any updates on this?

ksi3321 avatar Jun 11 '18 08:06 ksi3321

Same here. I have RV items with different layout files and different heights. But the height always seems to be the width of a column!?

DennyWeinberg avatar Nov 30 '18 13:11 DennyWeinberg

The issue with allowing custom heights - besides making the layouting algorithm more complex - is again the ordering used by the layout manager and failing at the problem it's trying to solve: placing all the items in the RV leaving as few gaps as possible.

One example would be this:

image

As the 3rd item is slightly taller than the rest of its row, it will affect all items below it and leave those 2 gaps there, that will probably never be filled. The more the items differ in width and heights, the more gaps will appear and the ordering will be affected.

As @prouland suggested, to prevent this the line or row height could be set to custom heights, instead of the items. Again, this would make the algorithm a lot more complex and require a big rewrite, which I can't do at the moment as I don't have the time.

jmartinesp avatar Nov 30 '18 16:11 jmartinesp