RecyclerView inside of NavigationDrawer not scrolling

Ali Najafi :

I've started a project and in this project I added a RecyclerView inside of NavigationView but for some reason the RecylerView not scrolling.

https://cdn1.imggmi.com/uploads/2019/7/31/d58464f32d8ebb24885b876f81ce2274-full.png

<androidx.drawerlayout.widget.DrawerLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="end"
    tools:openDrawer="end">

    <com.google.android.material.navigation.NavigationView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="right">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <include layout="@layout/digikala_navigation_drawer_header" android:id="@+id/navigationDrawerHeader"/>
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/navigationDrawerRecyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/navigationDrawerHeader">

        </androidx.recyclerview.widget.RecyclerView>
        </RelativeLayout>
    </com.google.android.material.navigation.NavigationView>

...

Mohsen mokhtari :

you should change content place with navigationView (navigationView must be last-child)

    <androidx.drawerlayout.widget.DrawerLayout 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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        tools:openDrawer="end">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
           // Content
        </LinearLayout>

        <com.google.android.material.navigation.NavigationView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="right">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            <include layout="@layout/digikala_navigation_drawer_header" android:id="@+id/navigationDrawerHeader"/>
            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/navigationDrawerRecyclerView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/navigationDrawerHeader">

            </androidx.recyclerview.widget.RecyclerView>
            </RelativeLayout>
        </com.google.android.material.navigation.NavigationView>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=135570&siteId=1