Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BottomSheetDialogFragment sets wrong background color for Dark theme

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?

like image 482
android_dev Avatar asked Jan 16 '17 13:01

android_dev


2 Answers

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>
like image 185
Tamás Szincsák Avatar answered Oct 20 '22 03:10

Tamás Szincsák


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"
like image 42
Vlastimil Eliáš Avatar answered Oct 20 '22 05:10

Vlastimil Eliáš