FlexboxLayoutManager did not display all items in NestedScrollView (item not displayed is hidden)
See original GitHub issue- I have searched existing issues and confirmed this is not a duplicate
Issues and steps to reproduce
Hello, I’m using a default configuration of FlexboxLayoutManager but does not able to display all items, from my log i can only receive 45/60 items (i’ve listed variations of results in ‘Expected Behavior’ column), I looked into issue 286 and 208 (and others) and it seems that they are all solved with latest version, as you can see below i’m using the latest version but i’m facing this issue, I apologized if i missed anything on my part, any suggestions and helps are really appreciated 😃, my configurations are as follows,
I’m using a default FlexboxLayoutManager such as this:
adapterCategory = new AdapterCategory(getActivity(), categories, this);
flmCategory = new FlexboxLayoutManager(getActivity());
rlvCategory.setAdapter(adapterCategory);
rlvCategory.setLayoutManager(flmCategory);
rlvCategory.setNestedScrollingEnabled(false);
rlvCategory.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (adapterCategory.holdersG.size() > 0) {
switchAllCategories.setChecked(true);
adapterCategory.setAllCategoriesTrue();
rlvCategory.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
}
});
with a layout like this for recyclerview (rlvCategory), as you can see i’m using it under LinearLayout and NestedScrollView:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView ... />
<TextView ... />
<android.support.v7.widget.RecyclerView ... />
<RelativeLayout ... />
<android.support.v7.widget.RecyclerView
android:id="@+id/rlvCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
tools:listitem="@layout/row_search_category" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
with something like this in my item layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp">
<ToggleButton
android:id="@+id/tbCategory"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:background="@drawable/background_rounded_gray_full"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:textAllCaps="false"
android:textColor="@android:color/black"
android:textSize="12sp" />
</RelativeLayout>
Expected behavior
I’m expecting my list to display all the items from my adapter but it does not display all of them. Currently my adapter would have 60 items and this is what i test:
-
If I use
flmCategory.setFlexDirection(FlexDirection.ROW);
, list will display up to 45 items. -
If I use
flmCategory.setFlexDirection(FlexDirection.ROW);
and set a fix height and remove paddings on my item layout, list will display up to 53 items. -
If I use
flmCategory.setFlexDirection(FlexDirection.COLUMN);
, list will display all 60 items.
Version of the flexbox library
Im using the latest 'com.google.android:flexbox:0.3.2'
version
Link to code
Please link to the code we can use to reproduce this issue. A complete project we can build/run is preferred, if you can’t provide one, please show us relevant code
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:44 (1 by maintainers)
Top GitHub Comments
I’ve looked into this and the issue seems to come from lines 620 - 629 in FlexboxHelper.
Commenting out this block does the trick :
I haven’t had the time to understand what this is supposed to optimize.
Hope this helps to solve the issue
v1.0.0, Is there a solution to this issue? the same problem I encountered?