Overscroll effect is not displayed correctly in NestedScrollView with RecyclerView inside

670 views Asked by At

I have NestedScrollView that contains some views and RecyclerView. But when I scroll RecyclerView, the overscroll effect is only shown in it. How do I display it in NestedScrollView?

I can disable overscroll effect in RecyclerView using android:overScrollMode="never" but I don't know how to enable overscroll effect in NestedScrollView while scrolling RecyclerView. I have already tried all the obvious solutions.

<androidx.core.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <!-- My views here -->

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </LinearLayout>

</androidx.core.widget.NestedScrollView>

gif

PS: I need to place my some views outside RecyclerView because otherwise RecyclerView adapter becomes unnecessarily complex (it is necessary to describe all types of elements). Please don't say this is bad for performance. In my case, this is irrelevant.

1

There are 1 answers

1
thanh On

Please go through NestedScrollView reference document for more information.

and add recyclerView.setNestedScrollingEnabled(false); to your RecyclerView