I'm using the support library 21 for my app. My theme is also defined in values-v21, but the DatePickerDialog
doesn't use the accent color for the background and text color.
What can I do to change this color to the accent color?
My current themes.xml are
values/themes.xml
<style name="AppTheme" parent="AppTheme.Base" />
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionModeOverlay">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
values-v21/themes.xml
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:colorPrimary">@color/colorPrimary</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorAccent">@color/colorAccent</item>
<item name="android:alertDialogTheme">@style/AppTheme.AlertDialog</item>
</style>
<style name="AppTheme.AlertDialog" parent="android:Theme.Material.Light.Dialog.Alert">
<item name="android:colorPrimary">@color/colorPrimary</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorAccent">@color/colorAccent</item>
</style>
Your dialog theme needs to extend Theme.AppCompat.Light.Dialog
instead of Theme.Material.Light.Dialog.Alert
. Here's an example:
<!-- Base Theme Styles -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- my theme stuff -->
...
<!-- dialog theme stuff -->
<item name="android:dialogTheme">@style/AppTheme.DialogTheme</item>
</style>
<!-- Styles for pop-up dialogs -->
<style name="AppTheme.DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="android:colorPrimary">@color/primaryColor</item>
<item name="android:colorPrimaryDark">@color/primaryColorDark</item>
<item name="android:colorAccent">@color/accentColor</item>
</style>
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