我有一个工作良好的抽屉布局,但我想禁用“从屏幕左侧到右侧拖动打开”,我该怎么做?
当前布局:
<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>发布于 2014-06-04 18:21:29
设置
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);其中mDrawerLayout是您的DrawerLayout
这会锁住你的抽屉
在您的按钮上单击,您可以打开和关闭它使用
if (mDrawerLayout.isDrawerOpen(mDrawerList))
mDrawerLayout.closeDrawer(mDrawerList);
else
mDrawerLayout.openDrawer(mDrawerList);其中mDrawerList是您的ExpandableListView
https://stackoverflow.com/questions/24034485
复制相似问题