google / flexbox-layout

Flexbox for Android
Apache License 2.0
18.22k stars 1.79k forks source link

flexboxlayoutmanager + recyclerview It cannot be fully displayed when there is a large amount of data #594

Open XIAOPOPO opened 2 years ago

XIAOPOPO commented 2 years ago

Use flexboxlayoutmanager + recyclerview to load the flow layout. There is no problem with normal display when the amount of data is small, but it cannot be fully displayed when the amount of data is large. You know why? 图片 As shown in the figure, there were more than 40 lines, but now only 20 lines are displayed。

TillSimon commented 1 year ago

Seeing the same behavior :/

TillSimon commented 1 year ago

If anyone else stumbles across this. If I see correctly, it's because of this

the amount of pixels where flex line calculation should be stopped this is needed to avoid the expensive calculation if the calculation is needed only the small part of the entire flex container. (E.g. If the flex container is the FlexboxLayoutManager, the calculation only needs the visible area, imposing the entire calculation may cause bad performance

I was using this for a RecyclerViewwithin a NestedScrollView. Users could switch between a horizontal LinearLayoutManager and a vertically expanded list with FlexboxLayoutManager. But as mentioned in the code comment, this is designed to only provide a proper height calculation up to a calculated visible area. But I needed that proper height to have the RecyclerView work correctly with wrap_content.

Setting setNestedScrollingEnabled to true let users scroll within that RecyclerView for the "missing" items. If this is not ideal, use FlexboxLayoutManager with a standard non-wrap_content RecyclerView or maybe the FlexboxLayout solves this.

wkp91 commented 1 year ago

I have the same problem, is there any way to solve it?

wkp91 commented 1 year ago

Problem and steps to reproduce

RecycleView nests RecycleView, and the internal RecycleView uses FlexboxLayoutManager(context, FlexDirection.ROW, FlexWrap.WRAP), when the number of items is large, it cannot be displayed completely (for example, only 30 items are displayed for 50 items, and they are not displayed after exceeding one screen)。

But when FlexboxLayoutManager is set to FlexDirection.COLUMN. Vertical display can all be displayed, and LinearLayoutManager or GridLayoutManager can also be used to display all

Only when FlexboxLayoutManager is set to FlexDirection.ROW is not fully displayed

Version of the flexbox library 3.0.0 and earlier

pantasystem commented 1 year ago

I am having the same issue.

Kusanali-zhao commented 1 year ago

I am having the same issue.

Does the item layout for RecyclerView use ConstraintLayout? Replacing ConstraintLayout with a RelativeLayout or LinearLayout might solve your problem.