How to set DayNight theme for BottomSheetDialog

1.3k Views Asked by At

I'm migrating to the new android DayNight theme.

I've replaced ThemeOverlay.AppCompat.Dark(Light).ActionBar to ThemeOverlay.AppCompat.DayNight.ActionBar

ThemeOverlay.AppCompat.Dark(Light) to ThemeOverlay.AppCompat.DayNight

Everything looks fine. Except that I cannot do the same with BottomSheetDialog. Does DayNight theme exist for BottomSheetDialog?

2

There are 2 best solutions below

0
Vadik Sirekanyan On BEST ANSWER

Yes, try to use Theme.MaterialComponents.DayNight.BottomSheetDialog. For some reason code completion isn't working in Android Studio for that case.

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
    ...
    <item name="bottomSheetDialogTheme">@style/Theme.MaterialComponents.DayNight.BottomSheetDialog</item>
</style>
0
Gabriele Mariotti On

To use the Material Components library you have to use a Material Components Theme

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">

If you can't use it, you should use a Bridge theme in your app:

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">