BottomSheetBuilder
BottomSheetBuilder copied to clipboard
Enable background dim while using a Builder with a coordinatorlayout?
I want to be a able to control the visibility of my BottomSheetDialog, so I'm using the builder with a coordinatorlayout provided. It seems however, that with that setup I can't enable background-dim? Could you suggest any workaround for this? Thank you in advance!
My suggestion would be placing a View with the background you want and then hide/show it according to the bottom sheet's visibility. If you pass a CoordinatorLayout, there's no BottomSheetDialog, but a plain View.
The main thing I want to achieve is have a BottomSheetDialog that I initialise once, and after that show()
and dismiss()
accordingly. This I can do fine with using a BottomSheetDialog. However, once I've dismissed it and show it again, the click is ignored in onBottomSheetItemClick
, because mClicked
is true (and is not set to false again after dismissing the dialog).
Ah, so you're reusing the same instance? I usually don't do this, so I didn't even think about it. I'll mark this as a bug and will fix it once I have time. Meanwhile, please create a new instance of a BottomSheetDialog every time you need one.
Yes, I'd like to use the same instance. Using Kotlin I'd like to do:
private val bottomSheet: BottomSheetMenuDialog by lazy {
// Create dialog
}
Thanks for your help!