Android 如何使顶层线性布局可通过其子项单击?

Android 如何使顶层线性布局可通过其子项单击?,android,xml,layout,Android,Xml,Layout,我已经建立了一系列相互叠加的线性布局,并使用weightSum将屏幕的各个部分分割起来。为了展示我希望发生的事情 现在的情况是橙色布局是可点击的,但是它只能在红色之后、绿色和蓝色之前的非常细的线条中点击。我想做的是,即使我点击蓝色或绿色,只要它在橙色范围内,橙色被按下。如何实现这一点?一个简单的解决方案是将LinearLayout的onClick参数设置为false 下面是一个简单的代码示例。从这里,您可以看到,无论您在屏幕上触摸到哪里,它都将激活Toast <?xml version="

我已经建立了一系列相互叠加的线性布局,并使用weightSum将屏幕的各个部分分割起来。为了展示我希望发生的事情


现在的情况是橙色布局是可点击的,但是它只能在红色之后、绿色和蓝色之前的非常细的线条中点击。我想做的是,即使我点击蓝色或绿色,只要它在橙色范围内,橙色被按下。如何实现这一点?

一个简单的解决方案是将
LinearLayout
onClick
参数设置为
false

下面是一个简单的代码示例。从这里,您可以看到,无论您在屏幕上触摸到哪里,它都将激活
Toast

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.android.test.MainActivity"
        android:onClick="youClicked">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clickable="false">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:clickable="false">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Hello"
                    android:textSize="80sp"
                    android:clickable="false"/>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

要进行简要说明,请将子
LinearLayout
onClick
参数设置为
false