I have a BottomSheet
in my Activity.
I'm calling behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
to show the bottom sheet and it works fine, but the problem I have is that I can somehow click on the empty space of my bottom sheet to trigger onClick
event of a view that is behind the bottom sheet.
Is there a way to prevent this from happening?
A simple solution is to add the android:clickable=true
attribute to the layout that you are using for your bottom sheet. That way it will capture all clicks, and not let them bleed through. You do not have to set an onClick
method for it, as you have no need to handle them.
来源:https://stackoverflow.com/questions/39734951/why-am-i-able-to-click-behind-the-bottomsheet-in-android