使用示例的Android Navigation Drawer bug

xla*_*8or 13 android sample navigation-drawer

我正在尝试根据我的应用实现导航抽屉模式.我从这里下载了示例代码并运行了它,并且90%的时间抽屉工作正常,但有时抽屉在我尝试打开时卡住了.我有办法复制情况,但并不总是有效.我做的是:

1-按原样运行示例代码.
2-将手指放在左边缘以使抽屉窥视
3-松开手指并将其按在主片上
4-尝试像往常一样打开抽屉

有时抽屉卡在偷看模式上,无论您向右滑动多少手指以更多地打开抽屉.有人有/修复过这个问题吗?

小智 19

我遇到了你提到的类似问题.我在相对布局(FILL_PARENT)中有一个列表视图.每当列表视图中的内容较少,并且当我在列表视图外部的区域中拖动时,导航抽屉就会被击中.android:clickable="true"相对布局的设置解决了问题.希望这可能有所帮助.

  • 您需要将`clickable ="true"设置为用于保存主要内容的布局. (2认同)

小智 16

要澄清Viji的答案,如果您使用的是提供的导航抽屉示例:

<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<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">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- android:layout_gravity="start" tells DrawerLayout to treat
         this as a sliding drawer on the left side for left-to-right
         languages and on the right side for right-to-left languages.
         The drawer is given a fixed width in dp and extends the full height of
         the container. A solid background is used for contrast
         with the content view. -->
    <ListView
        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.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

添加android:clickable="true"到FrameLayout似乎解决了这个问题.