• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

NestedScrollView does not scroll when RecyclerView scrolls

umtblbl

Member
Hi friends, I have a RecyclerView in NestedScrollView. I set the size of the RecyclerView according to the screen size of the user. In this case, the recyclerview layout_height is 700dp, for example.

In this case, the problem is; The NestedScrollView does not scroll while the recyclerView is scrolling, and the nestedScrollView.setOnScrollChange method is not triggered.

What I want is; When scrolling on the recyclerView, NestedScrollView is also shifted and the nestedscrollView.setOnScrollChange method is triggered in any case. I've shared the layout below.
Is there anyone who can help?

Code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/nestedScrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

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

                <androidx.appcompat.widget.SearchView
                    android:elevation="10dp"
                    android:id="@+id/searchView"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:layout_margin="4dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="8dp"
                    android:layout_marginEnd="8dp"
                    android:background="@color/colorAccent" />

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="4dp"
                    android:layout_marginTop="8dp"/>
            </LinearLayout>


</androidx.core.widget.NestedScrollView>
 
Back
Top Bottom