LinearLayout里子view点击,其他空白间隙处禁止点击

经过不断摸索终于实现了。
像头条里黄色区域禁止点击实现。
可以通过在父 LinearLayout 上设置 android:clickable="true" 属性来实现,然后在子 View 上设置 android:clickable="false" 属性。这样子 View 将不会响应点击事件,而空白的区域仍然可以响应点击事件。
示例代码如下:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:orientation="vertical">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:clickable="false" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:clickable="false" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:clickable="false" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:clickable="false" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:clickable="false" />
</LinearLayout>


















![表名注解/主键注解/字段注解/乐观锁注解[MyBatis-Plus系列] - 第486篇](https://img-blog.csdnimg.cn/img_convert/fdca442828cb39d52862e1e918f03ee7.png)
