Today's project requires that when webview is loading, a layer will pop up, showing that it is loading, and the background is transparent. Then it meets that when the layer pops up, the back can still click, so android:clickable = "true" is set in the middle
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#55000000"
android:clickable="true"
android:visibility="visible">
<RelativeLayout
android:layout_width="360dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
android:background="@drawable/shape_10">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<View
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:background="@drawable/loadingtianshi" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="26dp"
android:clickable="false"
android:gravity="center_vertical"
android:text="Loading, please wait"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
However, strange things happened. When clicking, click monitoring really can't penetrate, but TextView's real "loading, please wait..." But it disappeared when clicking. Finally, the layer was changed in java
//Prevent click through problems
relativeLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
});
To prevent textview messages from missing when clicking:
Key treatment:
Layer Android: layout? Centerinparent = "true"
Set the touch monitor of the layer, that is, consume the click
relativeLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
});