【问题标题】:DrawerLayout End gravity. Drawer not opening with edge swipe when as childDrawerLayout 结束重力。小时候抽屉不能用边缘滑动打开
【发布时间】:2016-06-16 18:01:45
【问题描述】:

我正在为我的活动设计横向布局。在横向活动中,我碰巧有下面带有 xml 代码的布局。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="wrap_content"
    android:layout_height="match_parent">
    <FrameLayout
        android:layout_width="200dp"
        android:background="@android:color/holo_blue_bright"
        android:layout_height="match_parent"/>
    <android.support.v4.widget.DrawerLayout
        android:layout_width="200dp"
        android:layout_height="match_parent">
        <FrameLayout
            android:layout_width="match_parent"
            android:background="@android:color/darker_gray"
            android:layout_height="match_parent"/>
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_gravity="end"
            android:background="@android:color/holo_red_light"
            android:layout_height="match_parent"/>
    </android.support.v4.widget.DrawerLayout>
</LinearLayout>

这里出现的问题是抽屉没有通过边缘滑动打开。顺便说一句,使用 LTR 布局,所以 end 是正确的。通过java调用打开抽屉,抽屉打开和触摸事件也被处理。此外,所有抽屉也都已解锁。但是当抽屉布局是水平方向的线性布局的子布局时,抽屉仍然不会通过从右边缘滑动打开。如果 linearLayout 中的第一个 Frame:ayout 宽度为零,则抽屉可以工作。

抽屉布局有什么问题?我该如何解决这个问题?

【问题讨论】:

    标签: android android-layout drawerlayout viewgroup


    【解决方案1】:

    来自 Android 参考资料:

    DrawerLayout 充当窗口内容的顶级容器

    DrawerLayout 必须是视图的根元素。不能嵌套在LinearLayout

    【讨论】:

      猜你喜欢
      • 2022-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-04
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      相关资源
      最近更新 更多