11

I have recyclerview in the nestedscrollview:

   <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <org.apmem.tools.layouts.FlowLayout
                android:id="@+id/filter_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/green_main"
                android:paddingLeft="@dimen/small_horizontal_margin"
                android:paddingRight="@dimen/small_horizontal_margin"
                />

            <android.support.v7.widget.RecyclerView
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                android:id="@+id/recycler_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clipToPadding="false"
                android:scrollbars="vertical"
                android:paddingTop="@dimen/vertical_margin"/>

        </LinearLayout>
  </android.support.v4.widget.NestedScrollView>

Recyclerview have OnScrollListener which is handling endless scrolling taken from this example: https://guides.codepath.com/android/Endless-Scrolling-with-AdapterViews-and-RecyclerView. However it seems like nestedscrollview is triggering onScrolled method, so whole list of items is loaded straight away.

Question: How I can prevent this beheviour?

Note, everything works perfect with recyclerview which isn't in nestedscrollview

  • 1
    did you got it working by any chance? – H.T May 20 '16 at 06:51
  • unfortunately no, I didn't have enough time to investigate this issue fully. Quick idea, try add scroll listener after all views are processed using OnGlobalLayoutListener – Eduards Denisjonoks May 20 '16 at 10:24
  • what i did is put everything as a header view in recycler view adapter so that the top view scrolls with recyclerview – H.T May 20 '16 at 11:26

1 Answers1

3

Try disabling nested scrolling on the RecyclerView:

recyclerView.setNestedScrollingEnabled(false);

Solved my issue with errant nested scrolling. Let me know if that helps.

lustig
  • 2,802
  • 17
  • 26