epoxy
epoxy copied to clipboard
EpoxyItemSpacingDecorator adding extra bottom spacing for certain items
See the following screenshots. The items in the middle of the row have extra bottom padding for some reason.
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.
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 👍
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.
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 any update on this?
Nothing has changed, sorry. I haven't been thinking about this. If anybody wants to propose a solution/PR I can take a look
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.
No updates from me - would welcome a PR from anyone interested in providing a better solution
any updates?
No updates from me - would welcome a PR from anyone interested in providing a better solution
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.