Android 防止抽屉布局通过触摸滑动
我有一个抽屉布局工作得很好,但我想通过从屏幕的左侧拖动到右侧来禁用打开,我该怎么做 当前布局:Android 防止抽屉布局通过触摸滑动,android,navigation-drawer,Android,Navigation Drawer,我有一个抽屉布局工作得很好,但我想通过从屏幕的左侧拖动到右侧来禁用打开,我该怎么做 当前布局: <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.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">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
class="net.MyFragment"
android:id="@+id/fragment_reading"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</fragment>
</FrameLayout>
<!-- The navigation drawer -->
<ExpandableListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"
android:cacheColorHint="#000000"
/>
/>
</android.support.v4.widget.DrawerLayout>
设置
您的抽屉布局在哪里
这会锁上你的抽屉
在您的按钮上单击,您可以使用打开和关闭它
if (mDrawerLayout.isDrawerOpen(mDrawerList))
mDrawerLayout.closeDrawer(mDrawerList);
else
mDrawerLayout.openDrawer(mDrawerList);
其中mDrawerList是您的可扩展列表视图在创建期间将其设置为锁定模式锁定关闭状态,并以编程方式打开/关闭。
if (mDrawerLayout.isDrawerOpen(mDrawerList))
mDrawerLayout.closeDrawer(mDrawerList);
else
mDrawerLayout.openDrawer(mDrawerList);