I have recently added BottomSheetDialogFragment to my app, but it shows background color for Material Dark theme as white. Even when I use
android:background="?android:attr/colorBackground"
for the root layout of the dialog, it is still white (but this attr is ok outside of the dialog). Has anyone ever had this problem?
The appearance of a bottom sheet dialog is controlled by an attribute named bottomSheetDialogTheme
, which defaults to Theme.Design.Light.BottomSheetDialog
. To achieve a dark background (and also white text, properly colored controls, etc.), you need to override it in your activity theme:
<style name="YourActivityTheme" parent="...">
<!-- ... -->
<item name="bottomSheetDialogTheme">@style/Theme.Design.BottomSheetDialog</item>
</style>
I just hit this problem. I used attribute you mentioned in the root layout of the dialog and it helped me.
android:background="?android:attr/colorBackground"
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