fix(RootLayout): prevent android touch event to pass through views underneath (#9389)

This commit is contained in:
William Juan
2021-05-12 07:43:56 +07:00
committed by GitHub
parent f380782766
commit 0b2c190662

View File

@@ -10,6 +10,26 @@ export class RootLayout extends RootLayoutBase {
super();
}
insertChild(view: View, atIndex: number): void {
super.insertChild(view, atIndex);
if (!view.hasGestureObservers()) {
// block tap events from going through to layers behind the view
view.nativeViewProtected.setOnTouchListener(
new android.view.View.OnTouchListener({
onTouch: function (view, event) {
return true;
},
})
);
}
}
removeChild(view: View): void {
if (view.hasGestureObservers()) {
view.nativeViewProtected.setOnTouchListener(null);
}
super.removeChild(view);
}
protected _bringToFront(view: View) {
(<android.view.View>view.nativeViewProtected).bringToFront();
}