-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FlexibleItemDecoration withOffset not working correctly for section headers #392
Comments
@omgreel, are you applying a sectionOffset with GridLayout? |
@davideas well, i'm not sure about gap, for me withOffset() seems to be broken. Here the code I used to reproduce this bug in your sample app. If you collapse all expandable headers and scroll to bottom you'll see no offset between last three headers. |
Ok thanks, to have noticed it. |
I will try to find some time to take a closer look to help you with it. My first suggestion is to use spanSize of item. I ran it on sample app in FragmentExpandableSection and it works in my case. But it's hard for me to say whether I broke something else or not. For example, there might be situation when spanCount = 3 |
@omgreel, 🆒 For the moment I do not see inconvenience. Let's use it. However, I also tried to remove completely the calculation of nextRowPos and it seems to work anyway. |
My suggestion requires lots of tests for different viewTypes, spanCounts, spanSizes and etc. Maybe I'll write test for isLastRowOrColumn method later. |
The proposed fix will be available in the next snapshot. |
…for section headers (use of spanSize)
Hi there.
I'm facing a simple bug when trying to add offset for my section headers with GridLayoutManager.
The problem is that offset won't applied for headers with
position == itemsCount - grid.spanCount - 1
.For example, if
GridLayoutManager spanCount == 2
, there is no offset between last and before last item.As I can see the problem is in
isLastRowOrColumn()
method.Specially in this part:
int nextRowPos = position < itemCount - (spanCount - spanIndex) ? position + (spanCount - spanIndex) : -1;
Assume we have 10 items and Grid's
columnCount == 2
.Since headers take whole width the
spanCount
will be equals 2, andspanIndex
will be 0.So, for the before last position the
position
will be 8.So we have
8 < 10 - (2 - 0)
which isfalse
, and the ternary result is -1.In method
return
statement there is... || nextRowPos == -1 || ...
condition, so we gettrue
for position before last.I'm using 5.0.0rc2 version of lib.
I would like any quick(!) suggestion how to fix it. Since I can't see the way to extend FlexibleItemDecoration and override relative methods.
Thanks.
The text was updated successfully, but these errors were encountered: