我的回收站视图位于导航抽屉的顶部

Me recycler view comes on top of the navigation drawer

我的回收站视图与我的导航抽屉重叠。以下是我对布局的代码-

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

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context="com.theappsolutes.shaadi.activities.HomeScreen">

    <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:scrollbars="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>


</RelativeLayout>

<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>

我想将回收站视图放在 activity 中,导航抽屉在顶部。请帮忙。

我的导航 header 是这样的 -

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark" android:orientation="vertical"
android:gravity="bottom">

<TextView android:id="@+id/user_full_name" android:layout_width="match_parent" android:layout_height="wrap_content"
    android:paddingTop="@dimen/nav_header_vertical_spacing"
    android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:id="@+id/user_email_id" />

</LinearLayout>

我的主抽屉是这样的-

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<group android:checkableBehavior="single">
    <item android:id="@+id/nav_logout" android:icon="@drawable/ic_power_settings_new_black_36dp"
        android:title="@string/logout" />
</group>

</menu>

这是我的工作版本:您需要 DrawerLayout 中的其他布局(如此处 RelativeLayout)。然后你应该包括你的 AppBar

<?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"
    layout_height="wrap_content"
    layout_width="wrap_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context="com.example.blablabla.MainActivity">

        <include
            android:id="@+id/app_bar"
            layout="@layout/app_bar"></include>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/newsList"
            android:layout_below="@+id/app_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal">

        </android.support.v7.widget.RecyclerView>
    </RelativeLayout>


    <fragment
        android:id="@+id/fragment_navigation_drawer"
        android:name="com.example.blabla.NavigationDrawerFragment"
        android:layout_width="@dimen/nav_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:layout="@layout/fragment_navigation_drawer"
        tools:layout="@layout/fragment_navigation_drawer"></fragment>
</android.support.v4.widget.DrawerLayout>

这是我的导航片段:在此示例中,NavigationDrawer 顶部有一个 ImageView,每个列表都有一个图像和文本。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.blabla.NavigationDrawerFragment"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/linid"
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:background="#0064a7"
        android:paddingLeft="20dp">

        <ImageView
            android:layout_width="240dp"
            android:layout_height="120dp"
            android:elevation="20dp"
            android:gravity="center_vertical"
            android:src="@drawable/zanderlogo" />
    </LinearLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/drawerList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </android.support.v7.widget.RecyclerView>    
</LinearLayout>