Search code examples
androidmaterial-designandroid-bottomsheetdialogtheme-daynight

How to set DayNight theme for BottomSheetDialog


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?


Solution

  • 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>