Why can I click “behind” the bottom sheet in android?

I have a BottomSheet in my activity.

I call behavior.setState(BottomSheetBehavior.STATE_EXPANDED); to show the bottom sheet, and it works fine, but the problem is that I can somehow click on the empty space of my bottom sheet to trigger the OnClick event of the view, which is behind the bottom sheet. Is there any way to prevent this?

+6
source share
1 answer

A simple solution is to add the android:clickable=true attribute to the layout you use for your bottom sheet. Thus, it will capture all clicks and not miss them. You do not need to set the onClick method for it, since you do not need to process them.

+9
source

All Articles