google / flexbox-layout

Flexbox for Android
Apache License 2.0
18.25k stars 1.8k forks source link

RecyclerView render issue if wrapped inside NestedScrollView #400

Open punitshah89 opened 6 years ago

punitshah89 commented 6 years ago

Issues and steps to reproduce

RecyclerView is not showing all items when list is long when used with FlexboxLayoutManager

  1. Wrap RecyclerView with android:nestedScrollingEnabled="false" inside NestedScrollView
  2. Create and add FlexboxLayoutManager to RecyclerView
  3. Load recycler view with long list of items

Expected behavior

RecyclerView should render all items

Version of the flexbox library

0.3.1, 0.3.2

Code example based on repro steps

  1. <android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/nested_scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:scrollbars="none"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:nestedScrollingEnabled="false"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
        />
    </android.support.v4.widget.NestedScrollView>
RecyclerView.LayoutManager layoutManager = new FlexboxLayoutManager(this.getContext());
mRecyclerView.setLayoutManger(layoutManager);
thagikura commented 6 years ago

Thanks for the report. Confirmed the behavior, but I don't come up with a usecase where RecyclerView is wrapped with a NestedScrollView in practice.

In what usecase do you expect that situation?

punitshah89 commented 6 years ago

Thanks for your quick reply, In my case I'm using multiple views including customRecyclerView inside NestedScrollView, where I want to make whole screen scroll instead of RecyclerView.

thagikura commented 6 years ago

But NestedScrollView if able to have only a single direct child. So it's not possible to make the entire screen scrollable including RecyclerView, no?

punitshah89 commented 6 years ago

Yes we can add root element to all views and screen is scrollable, in my case I'm using RelativeLayout and following structure.

<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
   android:id="@+id/nested_scroll_view"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:fillViewport="true"
   android:scrollbars="none"
   app:layout_behavior="@string/appbar_scrolling_view_behavior">

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

<Otherviews />
<CustomRecyclerView />

</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
thagikura commented 6 years ago

Oh so the actual XML was different from the one you pasted in the first comment. Understood.