导航抽屉关闭空的空间点击

时间:2016-01-20 09:22:02

标签: android navigation-drawer android-navigation-drawer

我使用了滑动菜单一段时间,现在我尝试使用导航抽屉。所以我对它不太满意。

我遇到的问题是如果用户点击非导航抽屉部件,我想关闭导航抽屉。

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

1 个答案:

答案 0 :(得分: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>
相关问题