There is a markup:

<?xml version="1.0" encoding="utf-8"?> <android.support.v4.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:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:openDrawer="start"> <android.support.design.widget.CoordinatorLayout 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"> <include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.v7.widget.RecyclerView android:id="@+id/card_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" /> </android.support.design.widget.CoordinatorLayout> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" /> </android.support.v4.widget.DrawerLayout> 

Wrapped in the CoordinatorLayout, but when you open the NavigationDrawer, the recycler is on top of all windows, and even when switching to another part of the application, on top of this recycler.

    1 answer 1

    1. In DrawerLayout, you can place only two (three, if menus with 2 sides are assumed) markup elements.
    2. One of them should be the left and / or right menu, and the other - the content
    3. To make the markup you want you need:
      1. Wrap AppBarLayout and RecyclerView in CoordinatorLayout
      2. Add behavior for RecyclerView like this:
     <android.support.v7.widget.RecyclerView android:id="@+id/card_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:scrollbars="vertical" /> 

    Those. the final layout should look schematically like this:

     DrawerLayout CoordinatorLayout AppBarLayout RecyclerView NavigationView 
    • Added approximately as follows, but still not correct ( - Inkognito
    • @Inkognito, I listed the correct solution. For me and for everyone it works. You are somewhere wrong. But you didn’t add new information to the question and you can’t guess where you made a mistake without it - YuriiSPb
    • I'm probably in the truth that something is wrong, but everything seems like you said. Question added. - Inkognito
    • @Inkognito, you forgot point 3.2 - Yuriy SPb