2016-01-20 138 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>