Skip to content

FlexboxItemDecoration not correct in FlexboxItemDecoration #336

Open
@ly85206559

Description

@ly85206559

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions