2017-04-08 154 views
-1

我用AndroidStudio.But附帶的DrawerLayout創建了一個活動。當我使用RecyclerView時,RecyclerView填滿了整個屏幕......?DrawerLayout與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> 

The Button on the left top can't be used.Guess it was coverd by RecyclerView

dsajfhkjasldfkj

+0

你不希望你的'RecyclerView'那裏。你需要把它放在內容'View'中;即''的佈局。你可能有一個'content_main'佈局。它會去那裏。 –

回答

0

你的佈局需要像這樣進行結構化:

​​
+0

謝謝你......我解決了它 –

+0

我很高興你能解決你的問題,然後回答我的問題。不過,如果你讚揚和/或標記我的答案,如果它幫助你:) –