-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Layout is invisible if first item is gone #283
Comments
Thanks for reporting. It's likely a bug with FlexboxLayout |
Hmm, I tried to reproduce it on my end, but couldn't reproduce it so far. Is it possible to share your reproducible code? <com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/flexbox_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:alignContent="flex_start"
app:alignItems="flex_start"
app:flexWrap="wrap"
tools:showIn="@layout/activity_main">
<TextView
android:id="@+id/textview1"
style="@style/FlexItem"
android:layout_width="@dimen/flex_item_length2"
android:layout_height="@dimen/flex_item_length"
android:text="@string/one"
android:visibility="gone"
/>
<TextView
android:id="@+id/textview2"
style="@style/FlexItem"
android:layout_width="@dimen/flex_item_length3"
android:layout_height="@dimen/flex_item_length"
android:text="@string/two" />
<TextView
android:id="@+id/textview3"
style="@style/FlexItem"
android:layout_width="@dimen/flex_item_length"
android:layout_height="@dimen/flex_item_length"
android:text="@string/three" />
</com.google.android.flexbox.FlexboxLayout> Thanks. |
I changed the visibility programmatically from visible to gone on the first item, maybe that could be the problem. |
Hmm, I change the visibility programmatically but the same result. I changed the OnClickListener in the FlexboxLayoutFragment addFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int viewIndex = mFlexContainer.getFlexItemCount();
// index starts from 0. New View's index is N if N views ([0, 1, 2, ... N-1])
// exist.
TextView textView = createBaseFlexItemTextView(activity, viewIndex);
FlexboxLayout.LayoutParams lp = new FlexboxLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
fragmentHelper.setFlexItemAttributes(lp);
textView.setLayoutParams(lp);
textView.setOnClickListener(new FlexItemClickListener(activity,
new FlexItemChangedListenerImpl(mFlexContainer), viewIndex));
mFlexContainer.addView(textView);
mFlexContainer.getFlexItemAt(0).setVisibility(View.GONE);
}
}); |
Here is a layout where the first item is set to GONE and the last item also disappears.
Maybe the disappearing of the whole layout is related to this bug. |
view is in the second line. In that case, the position of the second view is misplaced. Fixes #283
Thanks for pasting the example layout. In that case, the second view's position is misplaced. |
Should be fixed by #300 |
Thank you for the fix. I found another issue that seems to be related. I created a new ticket #303 |
I have a layout with multiple children and when I set the first item to View.GONE the whole layout is invisible. If I only set the second item to gone the layout works fine.
There seems to be a problem with calculating flexLine.mItemCount, in this line [0] it's always 1 when the first item is gone.
[0] https://github.com/google/flexbox-layout/blob/dev_recyclerview/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayout.java#L658
The text was updated successfully, but these errors were encountered: