Adding RecyclerView inside of DrawerLayout

好久不见. 提交于 2019-11-29 08:50:50

First, you can remove android:padding="16dp" from the LinearLayout, that is why you see "blank space" around the list.

Then you want wrap_content height on the <include-d app bar layout so that it does not take the whole space.

And simply move the LinearLayout outside of the NavigationView

<?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"
    ...


    <!-- here is the content -->
    <LinearLayout
        android:orientation="vertical"
        ...
        >

        <!-- here is the toolbar -->
        <include
            layout="@layout/app_bar_main"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        ...
        <RecyclerView
            ...
            />
    </LinearLayout>

    <!-- here is the drawer -->
    <NavigationView
        android:layout_gravity="start"
        ... >

    </NavigationView>

</DrawerLayout>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!