epoxy icon indicating copy to clipboard operation
epoxy copied to clipboard

EpoxyItemSpacingDecorator adding extra bottom spacing for certain items

Open chrisbanes opened this issue 7 years ago • 11 comments

See the following screenshots. The items in the middle of the row have extra bottom padding for some reason.

Screenshot 1 Screenshot 2

chrisbanes avatar Jan 01 '18 15:01 chrisbanes

Ah ok, realised what the issue is. My layouts are using ConstraintLayout aspect ratio constraints for the height/width. Since EpoxyItemSpacingDecorator does not use uniform spacing for all items in a row, the item widths are different, which results in the heights being different too.

I can't think of a nice way to fix that without forcing the items to have padding on their closest edge to the RecyclerView, so closing.

chrisbanes avatar Jan 01 '18 15:01 chrisbanes

Thanks for pointing this out, its an unfortunate flaw. I've been thinking about how we can fix this, since it will be a common issue.

One basic way might be to apply the item decoration spacing to all sides of every item, and reduce the recyclerview side padding by the corresponding amount (ie for 6dp spacing, put 3dp on all sides of every item and reduce the recyclerview side padding by 3dp).

That would be a very simple item decorator class, and at first thought it seems like it could work, but I am just getting back from vacation so I need to get back in the swing of things :P I'll keep thinking about it, please let me know if you have any ideas 👍

elihart avatar Jan 02 '18 20:01 elihart

Yeah that's exactly what I do in Tivi but it forces you to set padding on the RecyclerView, which is different to what EpoxyRecyclerView currently provides. It works nicely in my scenario since I just set 2dp left/right padding on RV, then 2dp left/right spacing on each item and get 4dp spacing + equal widths (and for top/bottom too).

If you don't want the outer padding though, you'll be forced to try and use negative padding on RV, which might work, but it's probably unspecified behavior.

I'll re-open for now.

chrisbanes avatar Jan 02 '18 20:01 chrisbanes

We could probably work something out where the outer item spacing is only if the user wants it. It would require more configuration options, but should be doable and I think we could probably find a happy middle ground that works for everybody.

I don't have time to tackle this soon, but let's leave it open, and anyone else is welcome to solve it :)

elihart avatar Jan 08 '18 21:01 elihart

@elihart any update on this?

gevariya-ajit avatar Apr 27 '18 19:04 gevariya-ajit

Nothing has changed, sorry. I haven't been thinking about this. If anybody wants to propose a solution/PR I can take a look

elihart avatar Apr 27 '18 20:04 elihart

Any new updates on this? It's even worse with the line item decorators - you end up with the line at the end of the recyclerView, we haven't found a way to solve this yet.

semanticer avatar Jan 17 '19 09:01 semanticer

No updates from me - would welcome a PR from anyone interested in providing a better solution

elihart avatar Jan 22 '19 03:01 elihart

any updates?

dbof10 avatar Sep 05 '19 14:09 dbof10

No updates from me - would welcome a PR from anyone interested in providing a better solution

elihart avatar Sep 10 '19 21:09 elihart

We have faced this issue on our project as well. In general, our fix has been to not use item spacing at all for epoxy recycler views using GridLayoutManagers and instead we add the spacing to the items. For instance, if you have a grid epoxy recycler view that should use item spacing 20dp, you would instead add spacing using a layout margin 10dp for your item layout and make your recycler view's margin 10dp smaller.

em135 avatar Mar 21 '22 15:03 em135