I want to change default Dialog background color of my PreferenceActivity (Dialog that opens where we choose option from list in settings). Now the background of Dialog is always white although I change it in my styles. I am trying to solve that like in my code but it does not work. Here are my light and dark styles.
styles.xml
<style name="Theme_ObjectMeasure_Light" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:textColor">#000000</item>
<item name="android:textColorPrimary">#000000</item>
<item name="android:textColorSecondary">@color/textColorSecondary</item>
<item name="alertDialogTheme">@style/DialogThemeLight</item>
<item name="dialogTheme">@style/DialogThemeLight</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowBackground">@color/bottom_nav_view_bg_night</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<item name="actionBarTheme">@style/Theme.MaterialComponents.DayNight</item>
<item name="android:actionBarStyle">@style/ThemeActionBar</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/ThemeActionBar</item>
<item name="windowActionBarOverlay">true</item>
</style>
<style name="Theme_ObjectMeasure_Dark" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:textColor">#ffffff</item>
<item name="android:textColorPrimary">#ffffff</item>
<item name="android:textColorSecondary">@color/textColorSecondary</item>
<item name="alertDialogTheme">@style/DialogThemeDark</item>
<item name="dialogTheme">@style/DialogThemeDark</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowBackground">@color/bottom_nav_view_bg_night</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<item name="actionBarTheme">@style/Theme.MaterialComponents.DayNight</item>
<item name="android:actionBarStyle">@style/ThemeActionBar</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/ThemeActionBar</item>
<item name="windowActionBarOverlay">true</item>
</style>
<style name="DialogThemeLight" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@color/bg_light</item>
</style>
<style name="DialogThemeDark" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@color/bg_dark</item>
</style>
colors.xml
<resources>
(...)
<color name="bg_light">#E0E0E0</color>
<color name="bg_dark">#424242</color>
</resources>
CodePudding user response:
I have read that on a newer devices the attributes with android: prefix should be used or to use AppCompat theme as a parent to get rid of confusing with this prefix.