若是你的NavigationDrawer裏面的Item沒有響應,Drawer不能左滑關閉

若是你的NavigationDrawer裏面的Item沒有響應,Drawer不能左滑關閉,應該是由於你沒有把主要內容放在DrawerLayout標籤下的第一位。html

The main content view (the FrameLayout above) must be the first child in the DrawerLayout because the XML order implies z-ordering and the drawer must be on top of the content.android

好比把CoordinatorLayout放在NavigationDrawer的第一位。app

更多:佈局

The main content view (the FrameLayout above) must be the first child in the DrawerLayout because the XML order implies z-ordering and the drawer must be on top of the content.
The main content view is set to match the parent view's width and height, because it represents the entire UI when the navigation drawer is hidden.
The drawer view (the ListView) must specify its horizontal gravity with the android:layout_gravity attribute. To support right-to-left (RTL) languages, specify the value with "start" instead of "left" (so the drawer appears on the right when the layout is RTL).
The drawer view specifies its width in dp units and the height matches the parent view. The drawer width should be no more than 320dp so the user can always see a portion of the main content.htm

一、顯示界面主要內容的View (上面的 FrameLayout ) 必須爲DrawerLayout的第一個子View, 緣由在於 XML 佈局文件中的View順序爲Android系統中的 z-ordering順序,而Navigation Drawer必須出如今內容之上。
二、顯示界面內容的View寬度和高度設置爲和父View同樣,緣由在於當Navigation Drawer不可見的時候,界面內容表明整個界面UI。
三、Navigation Drawer (上面的 ListView) 必須使用android:layout_gravity屬性設置水平的 gravity值 .若是要支持 right-to-left (RTL,從右向左閱讀)語言 用 "start" 代替 "left" (當在 RTL語言運行時候,菜單出如今右側)。
四、抽屜菜單的寬度爲 dp 單位而高度和父View同樣。抽屜菜單的寬度應該不超過320dp,這樣用戶能夠在菜單打開的時候看到部份內容界面。ci

http://developer.android.com/training/implementing-navigation/nav-drawer.htmlget

相關文章
相關標籤/搜索