在XML布局中出现重叠的View,位置靠后定义的View会覆盖住位置靠前的View;即靠后的View会拦截触碰事件导致靠前的View无法收到触碰事件,无法触发监听器。
//例.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout ... ...>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout_1" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout_2"/>
</androidx.constraintlayout.widget.ConstraintLayout>
// layout_2会覆盖住layout_1;导致layout_1无法接收到触摸事件