androidandroid-recyclerviewendlessscrollandroid-nestedscrollview

Recyclerview with endless scrolling in nestedscrollview, triggers onScrolled


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


Solution

  • Try disabling nested scrolling on the RecyclerView:

    recyclerView.setNestedScrollingEnabled(false);
    

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