Skip to content

Commit 2ebf28f

Browse files
imhappipaulfthomas
authored andcommitted
[BottomNavigationView] Consume all touch events in BottomNavigationView so touch events are not passed to the view underneath
PiperOrigin-RevId: 703309708
1 parent 4f7bf29 commit 2ebf28f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/java/com/google/android/material/bottomnavigation/BottomNavigationView.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020

2121
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
2222

23+
import android.annotation.SuppressLint;
2324
import android.content.Context;
2425
import androidx.appcompat.widget.TintTypedArray;
2526
import android.util.AttributeSet;
27+
import android.view.MotionEvent;
2628
import android.view.View;
2729
import androidx.annotation.NonNull;
2830
import androidx.annotation.Nullable;
@@ -127,6 +129,14 @@ public BottomNavigationView(
127129
applyWindowInsets();
128130
}
129131

132+
@SuppressLint("ClickableViewAccessibility")
133+
@Override
134+
public boolean onTouchEvent(@NonNull MotionEvent event) {
135+
super.onTouchEvent(event);
136+
// Consume all events to avoid views under the BottomNavigationView from receiving touch events.
137+
return true;
138+
}
139+
130140
private void applyWindowInsets() {
131141
ViewUtils.doOnApplyWindowInsets(
132142
this,

0 commit comments

Comments
 (0)