Open ywwynm opened 7 years ago
I thought it's supported. Could you share your XML configuration for the RecyclerView and the settings for the FleboxLayoutManager?
@thagikura My layout(for a BottomSheet
and is included in main layout) is:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:behavior_peekHeight="56dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
And item's layout:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="42dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
And settings for FlexboxLayoutManager
(in kotlin and actually settings are default ones):
val flm = FlexboxLayoutManager(this)
rv.layoutManager = flm
@thagikura Actually the bug is: some last line won't be shown under some circumstances(I'm still working on finding what these conditions are), not "only shows first line".
Thanks for the info. I guess the height may be constrained by another component. When the last line isn't shown, is the bottom sheet fully shown or is it in its peek position?
@thagikura I think I find the reason causes the bug: if the item of RecyclerView
is a TextView
having a compound drawable, then the display will not be correct. However, if I replace it with an ImageView
and a TextView
inside a LinearLayout
to achieve same effect, then the RecyclerView
will show all items.
Please import attached demo project below and take a look at the bug. Thank you.
FlexboxLayoutManagerBug.zip
Thanks for creating the test project. Confirmed the weird behavior, the issue seems to be caused if any compound drawables are included in the item in the RecyclerView.
In the initial call of the onLayoutChidlren, the width of the TextViews haivng a compound drawable seems to be calculated as if they don't have the compound drawable. As a result, the number of flex lines is shorter than expected.
Let me mark this as a bug.
@thagikura Thanks. I will wait for the fix but currently the LinearLayout
stuff is adoptable.
Looks like I have the same behavior when TextView in ListItem has custom background (like this in my case:)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/color_tag_background" />
<stroke
android:width="1dp"
android:color="@color/color_tag_border" />
<corners android:radius="12dp" />
</shape>
if we have three items at one line with linear layout manager then change for flex layout manager, only two items will be shown on and third one will be on next line
Also happens when using android.support.design.chip.Chip. In some instances the FlexboxLayoutManager is able to wrap the list of items and create a new line, however in some conditions it doesn't and the item is shown after scrolling the recyclerView. Does anyone know a workaround for this?
I am seeing the same bug with items that have a constraintlayout parent, with textview and imagebutton as children.
If the
RecyclerView
's height is wrap_content, only one line of items will be shown and we should scroll theRecyclerView
to see the second line(FlexDirection
isROW
). It was said that ifFlexWrap
is set toWRAP
, multiple lines will be shown but the fact is not like that. Please support this, thanks.