BottomSheetBuilder icon indicating copy to clipboard operation
BottomSheetBuilder copied to clipboard

Enable background dim while using a Builder with a coordinatorlayout?

Open SammyO opened this issue 7 years ago • 4 comments

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!

SammyO avatar Oct 31 '17 10:10 SammyO

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.

rubensousa avatar Oct 31 '17 10:10 rubensousa

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).

SammyO avatar Oct 31 '17 10:10 SammyO

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.

rubensousa avatar Oct 31 '17 10:10 rubensousa

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!

SammyO avatar Oct 31 '17 10:10 SammyO