机器人 - 透支布局允许触摸过的LinearLayout [英] android - overdraw layout allows touch through LinearLayout

查看:119
本文介绍了机器人 - 透支布局允许触摸过的LinearLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

请参阅附件中的例子。

感谢您

 < RelativeLayout的
     的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / rlExtNavbar
    机器人:方向=垂直
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:重力=fill_vertical
    机器人:layout_gravity =fill_vertical
    机器人:背景=@色/透明的xmlns:工具=htt​​p://schemas.android.com/tool​​s工具:忽略=透支>
    < RelativeLayout的
        机器人:ID =@ + ID / expandedNavbarLayout
        机器人:方向=垂直
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT>
    < / RelativeLayout的>
    <的LinearLayout
        机器人:ID =@ + ID / transparentLayout
        机器人:方向=垂直
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ ID / expandedNavbarLayout
        机器人:focusableInTouchMode =假
        机器人:可聚焦=假
        机器人:背景=@色/ fulltransparent>
    < / LinearLayout中>

< / RelativeLayout的>
 

解决方案

只需设置机器人:可点击=真正的在XML属性中的LinearLayout将prevent的点击经历 - 无需点击监听器

in the following UI I have this below drabable overlaying the entire screen. The LinearLayout is transparent and allows controls below it to be clickable or touchable. Basically I can scroll a list below this LinearLayout as well as click controls. How do I disable that?

See attached example.

Thank you

<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>

解决方案

Just setting the android:clickable="true" property for the LinearLayout in the XML will prevent the clicks going through -- no need for a click listener.

这篇关于机器人 - 透支布局允许触摸过的LinearLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆