简体   繁体   中英

Overscroll effect is not displayed correctly in NestedScrollView with RecyclerView inside

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.

Please go through NestedScrollView reference document for more information.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM