Android 抽屉布局与RecyclerView冲突?回收视图填充整个屏幕

Android 抽屉布局与RecyclerView冲突?回收视图填充整个屏幕,android,Android,我使用AndroidStudio中附带的DroperLayout创建了一个活动。但是当我使用RecyclerView时,RecyclerView填充了整个屏幕 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schem

我使用AndroidStudio中附带的DroperLayout创建了一个活动。但是当我使用RecyclerView时,RecyclerView填充了整个屏幕

<?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"
tools:openDrawer="start">
    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <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.v7.widget.RecyclerView
        android:layout_marginTop="20dp"
        android:id="@+id/titleList"
        android:layout_width="match_parent"
        android:layout_height="80dp"/>
</android.support.v4.widget.DrawerLayout>


dsajfhkjasldfkj

您的布局需要如下所示:

 <DrawerLayout>

   //Main View
    <RelativeLayout>

        //this will show in your main Content,


    </RelativeLayout>

  //Second View 

    <LinearLayout>

        //this will be seen on your drawerlayout

    </LinearLayout>
 </DrawerLayout>

//主视图
//这将显示在你的主要内容中,
//第二视图
//这将显示在您的抽屉布局上

您不希望您的
回收视图出现在那里。您需要将其放在内容
视图中
;i、 例如,
的布局。您可能有一个
content\u main
布局。我很高兴你能按照我的回答解决你的问题。不过,如果您投票并/或将我的答案标记为有助于您的答案,那就太好了:)