android - 过度绘制布局允许通过 LinearLayout 进行触摸

标签 android controls touch overlay android-linearlayout

在下面的 UI 中,我有这个覆盖整个屏幕的下拉菜单。 LinearLayout 是透明的,并允许其下方的控件可点击或可触摸。基本上,我可以滚动此 LinearLayout 下方的列表以及单击控件。如何禁用它?

见附件示例。 enter image description here

谢谢

<RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rlExtNavbar" 
    android:orientation="vertical"
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:gravity="fill_vertical"
    android:layout_gravity="fill_vertical"
    android:background="@color/transparent" xmlns:tools="http://schemas.android.com/tools" tools:ignore="Overdraw">
    <RelativeLayout
        android:id="@+id/expandedNavbarLayout" 
        android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" >
    </RelativeLayout>
    <LinearLayout
        android:id="@+id/transparentLayout" 
        android:orientation="vertical"
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"
        android:layout_below="@id/expandedNavbarLayout"
        android:focusableInTouchMode="false"
        android:focusable="false"
        android:background="@color/fulltransparent">
    </LinearLayout>

</RelativeLayout>

最佳答案

只需在 XML 中为 LinearLayout 设置 android:clickable="true" 属性将阻止点击通过 -- 不需要点击监听器。

关于android - 过度绘制布局允许通过 LinearLayout 进行触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10129092/

相关文章:

java - Android 加载全图 Recyclerview Cardview

android - 如何更改android中最近应用列表显示的屏幕截图?

c# - 当它在asp.net中没有图像时如何使图像框不可见

javascript - 点击悬停区域中的链接会在触摸时立即激活

android - 如何在 Flutter 中使用 Dio 和 multi_image_picker 插件上传多张图片

java - 在嵌套方法中更新变量不会全局更新它

c# - 在 winforms 中创建动态 UI

.net - Border 不继承 Control,那么 Control.Background 上的 setter 是如何工作的呢?

internet-explorer - IE 10 的用户代理字符串末尾的 6 个字符是什么?

ios - 在 SpriteKit 中检测对象子节点上的触摸