fondesa / recycler-view-divider

A library which configures a divider for a RecyclerView.
Apache License 2.0
507 stars 45 forks source link

GridLayoutManager/StaggeredGridLayoutManager item width not equal #79

Closed AcgnCodeMonkey closed 4 years ago

AcgnCodeMonkey commented 4 years ago

Description

if i use GridLayoutManager,the item width was not equal

RecyclerViewDivider version:

v3.1.0 API level:

How to reproduce it:

Sample code:

RecyclerViewDivider.with(rv.getContext()) .insetManager(new DefaultInsetManager()) .hideLastDivider() .size(size) .color(ResUtils.getColor(color)) .build().addTo(rv);

QQ截图20200417133758 QQ截图20200417133818

fondesa commented 4 years ago

I'm already aware of this bug. It happens when you use a GridLayoutManager with more than two columns and a divider size bigger than 2dp.

The problem here is the limitation of the Android API which computes the offset only of the current item ItemDecoration.getItemOffsets instead of the offsets of all the visible items.

The fix is not easy and it won't cover some cases (e.g. balancing an item offset of 4 items where the 2nd item hasn't a divider) since the item offset should be balanced between the items to render the same items width.

I've already tried to support this case in the version 3.2.0 without success.

I'll try again to fix it before releasing the version 3.2.0 but I'm not sure I'll be able to make it working. If you have some idea of how to fix it, the contributions are well accepted and since the 3.2.0 is in development we can directly fix it there.

fondesa commented 4 years ago

@AcgnCodeMonkey I've found a way to do it but it requires a huge amount of work to support it. So I'm going to work on the 3.2.0 release without this feature and then I'll try to add this feature after. I still don't know if I can manage to develop this feature alone since it requires to auto-balance dinamically all the offsets.

fondesa commented 4 years ago

Same issue: https://github.com/fondesa/recycler-view-divider/issues/106

fondesa commented 4 years ago

Fixed in the version 3.3.0 (only using the new API, not the legacy one).