如何仅在特定的线性布局上通过水平滑动打开抽屉?

问题描述

我有一个非常简单的活动,有一个抽屉和两个线性布局。 我需要实现:如果我们在按钮布局的任何位置水平向右滑动,它将打开抽屉(与 Telegram 应用程序中的相同)。但它不应该在顶部布局上打开它,因为它包含一个寻呼机。

你能帮我实现它吗?

enter image description here

解决方法

将抽屉布局设为父布局。将您的视图放在抽屉布局中。

<!-- Use DrawerLayout as root container for activity -->
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

//Your view here

</androidx.drawerlayout.widget.DrawerLayout >

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...