Skip to content
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

FlexboxItemDecoration not correct in FlexboxItemDecoration #336

Open
1 task
ly85206559 opened this issue Jul 25, 2017 · 9 comments
Open
1 task

FlexboxItemDecoration not correct in FlexboxItemDecoration #336

ly85206559 opened this issue Jul 25, 2017 · 9 comments
Labels

Comments

@ly85206559
Copy link

Issues and steps to reproduce

if i do not use decoration,the flexboxlayoutmanager show correct,if i user decoration,the each item of recycle view do not show fully.
Like this:
not use decoration
Text1Text2Text3Text4
Text5Text6Text7Text8
use decoration
Tex... Tex... Tex... Tex...
Tex... Tex... Tex... Tex...

Expected behavior

like this:
Text1 Text2 Text3
Text4 Text5 Text6
Text7 Text8

Version of the flexbox library

e.g. 0.2.6, 0.3.0-alpha3

Link to code

    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    TagAdapter adapter = new TagAdapter(this, Arrays.asList(tags));
    recyclerView.setAdapter(adapter);

    FlexboxLayoutManager manager = new FlexboxLayoutManager(this, FlexDirection.ROW);
    manager.setFlexWrap(FlexWrap.WRAP);
    recyclerView.setLayoutManager(manager);
    FlexboxItemDecoration decoration = new FlexboxItemDecoration(this);
    decoration.setOrientation(FlexboxItemDecoration.BOTH);
    decoration.setDrawable(getDrawable(R.drawable.divider));
    recyclerView.addItemDecoration(decoration);

I read the source code ,and i think there maybe have problem.
in FlexBoxHelper->isWrapRequired method
int decorationLength =
mFlexContainer.getDecorationLengthMainAxis(view, index, indexInFlexLine);
this line return 0 but i set the decoration.

And i find must invoke calculateItemDecorationsForChild(view,rect) first, otherwise can not get the correct decoration

@thagikura
Copy link
Contributor

Thanks for filing this.

As you say it looks like the decoration length should be calculated before calling the isWrapRequired method

@thagikura thagikura added the bug label Jul 26, 2017
@ly85206559
Copy link
Author

Thanks , and i am now working on it.

@thagikura
Copy link
Contributor

That would be great. Thanks for doing that.

ly85206559 added a commit to ly85206559/flexbox-layout that referenced this issue Aug 2, 2017
This is not the best sulotion,but now it can resolve the problem.
This problem is not so easy.
Calculate the decoration is conflict with the method isWrapRequired,and i can not reuse the view for both calculate the decoraion and isWrapRequired.
So this solution is just for get the decoration with the view,and the capability maybe not so good.But it certenly solve the problem.
@ghost
Copy link

ghost commented Aug 24, 2017

Are there any timely plans for this to get merged and making a new release?

@thagikura
Copy link
Contributor

Sorry at this moment, there isn't a fixed plan when this is fixed.
This issue isn't as easy as it looks.

@ghost
Copy link

ghost commented Aug 24, 2017

That's sad because right now Item Decorations can't be used with Flexbox Layout Manager

@thagikura
Copy link
Contributor

Let me try to fix it before too long.

@hangnadi
Copy link

hangnadi commented Apr 23, 2018

is it still ? I use v0.3.2

@HelenaSewell
Copy link

I'm also encountering this issue. What's odd is that if I set my (TextView) items to be single line, the text gets cut off, but the textview itself appears to be the correct size. Sort of like this: [an-_____].
This only happens on lines just at the point of being long enough to move the item. (This means that the smaller the width of the items, the more likely this is to happen)
Using 0.3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants