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?
set bottomSheet onClickListener to null. bottomSheet. setOnClickListener(null); this line disables all action about bottomSheet only and does not effect on inner view.
Using the Interface - onSlide which as a parameter slideOffSet of type float , can be used to dim the background. The new offset of this bottom sheet within [-1,1] range. Offset increases as this bottom sheet is moving upward.
clickable seems to be useful when you need a view to consume clicks so that they do not go to views beneath the top view. For example, I have a FrameLayout that I display over an underlying RelativeLayout at certain times. When the user would click on an underlying EditText the focus would shift to that EditText .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With