flexbox-layout icon indicating copy to clipboard operation
flexbox-layout copied to clipboard

Cannot access current FlexLine from ItemDecoration.getItemOffsets

Open technoir42 opened this issue 5 years ago • 1 comments

I'm trying to implement a custom ItemDecoration to assign offsets for each item (somewhat similar to FlexboxItemDecoration). To calculate the offsets in getItemOffsets I need to know the relative position of the item in the current flex line.

The problem is at the moment when getItemOffsets is called the current FlexLine is not added yet to FlexboxLayoutManager.getFlexLinesInternal() and I've found no other way to get the relative position.

Would it be possible to add the current FlexLine to list before getItemOffsets gets called or provide some other way to obtain item position in a flex line?

Just for illustration, this is kind of layout I'm trying to achieve: Imgur

technoir42 avatar Sep 21 '18 10:09 technoir42

Hi @technoir42

Unfortunately it's not possible at this moment. I tried the similar implementation, but realized it needs to access the package private members of the ViewHolder, which aren't exposed.

So I recommend to use FlexboxLayout at this moment.

Please let me know if something is not clear.

thagikura avatar Dec 14 '18 08:12 thagikura