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
This example demonstrates how do I use RecyclerView inside NestedScrollView in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Add the following dependency in the build.gradle (Module: app)
This component allows you to not only scroll through views that extend the size of the device screen but also use complex layouts inside like the RecyclerView. When using a NestedScrollView in combination with RecyclerView, nested scrolling is enabled by default.
Although RecyclerView has a very good and smooth scrolling built-in, but when you put into any ScrollView, then your RecyclerView ’s scrolling will not work. For example, Now, the RecyclerView will not scroll. To fix that, you will have to use NestedScrollView instead of ScrollView like this:
You can use android:fillViewport="true" to make NestedScrollView measure the RecyclerView. The RecyclerView will fill the remaining height. so if you want to scroll the NestScrollView, you can set the RecyclerView's minHeight.
Try disabling nested scrolling on the RecyclerView:
recyclerView.setNestedScrollingEnabled(false);
Solved my issue with errant nested scrolling. Let me know if that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With