2016-01-20 63 views
0

我用了一段時間slidingmenu現在我嘗試使用導航抽屜。所以我不那麼舒服。導航抽屜關閉空的空間點擊

我遇到的問題是如果用戶點擊非導航抽屜部件,我想關閉導航抽屜。

| | | | | | | | | | x抽屜| ---屏幕---- | | | | | | | | | |

如果用戶點擊屏幕部分我想關閉抽屜。

其中一個問題是屏幕是隨抽屜項目點擊而變化的片段。

< 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_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true" /> 


<include 
    layout="@layout/side_menu_layout" 
    android:layout_width="100dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" /> 



</android.support.v4.widget.DrawerLayout> 

回答

2
<android.support.v4.widget.DrawerLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
<android.support.design.widget.NavigationView 
      android:id="@+id/nav_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:background="#F2FFFFFF" 
      android:dividerHeight="0dp" 
      android:divider="@android:color/transparent" 
      android:choiceMode="singleChoice" 
      android:fitsSystemWindows="true"> 
     <include 
      layout="@layout/sideview_layout" 
      android:id="@+id/left_drawer" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
     </android.support.design.widget.NavigationView> 

    </android.support.v4.widget.DrawerLayout>