I'm having a hard time trying to style a ListPreference.
I've applied a main theme which declares a preferenceTheme and both of them link to a dialogTheme (and alertDialogTheme respectively). It works except that the text color of the items doesn't change - but the color of all other texts does. I cannot rely on a workaround because I'm using the v7 preferences and thus cannot override the dialog methods in a custom class.
For me it looks like the rows ignore the text color value, but maybe someone else has a solution for this. Otherwise this might be a bug?
Main style:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- [...] -->
<!-- Some color values -->
<item name="android:dialogTheme">@style/DialogTheme</item>
<item name="android:alertDialogTheme">@style/DialogTheme</item>
<item name="dialogTheme">@style/DialogTheme</item>
<item name="alertDialogTheme">@style/DialogTheme</item>
<item name="preferenceTheme">@style/PreferenceTheme</item>
</style>
PreferenceTheme:
<style name="PreferenceTheme" parent="PreferenceThemeOverlay.v14.Material">
<!-- [...] -->
<!-- Some color values -->
<item name="android:textColor">@color/preference_primary_color</item>
<item name="android:textColorPrimary">@color/preference_primary_color</item>
<item name="android:textColorSecondary">@color/preference_primary_color</item>
<item name="android:textColorHighlight">@color/preference_primary_color</item>
<item name="android:editTextColor">@color/preference_primary_color</item>
<item name="android:dialogTheme">@style/DialogTheme</item>
<item name="android:alertDialogTheme">@style/DialogTheme</item>
<item name="preferenceTheme">@style/PreferenceTheme</item>
</style>
DialogTheme:
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColor">#EEEEEE</item>
<item name="android:textColorPrimary">#EEEEEE</item>
<item name="android:textColorSecondary">#EEEEEE</item>
<item name="android:textColorHighlight">#EEEEEE</item>
<item name="android:textColorTertiary">#EEEEEE</item>
<item name="android:textColorAlertDialogListItem">#EEEEEE</item>
<item name="android:editTextColor">#EEEEEE</item>
<item name="color">#EEEEEE</item>
</style>
This is how it looks.The text should be #EEEEEE
. I've snipped it but the text colors are applied in each of the given styles.
You did everything right, except one thing: do not use the
android
prefix when overridingtextColorAlertDialogListItem
because this is not the framework version ofAlertDialog
.This statement is generally true for almost all attributes that belong to the support widgets / views. The reason is pretty straightforward: not all attributes are available on the older platforms. Such example is
android:colorControlActivated
which was introduced in API 21. The AppCompat lib declares its owncolorControlActivated
so it's available on older API levels, too. In this case the developer should not use theandroid
prefix when defining the style in the theme as that would point to the platform version of the attribute instead of the AppCompat one.TL;DR: Do not use the
android
prefix for support widgets unless you have to (i.e. you get compilation error).P.S.: I have created a fix / extension to the support preferences-v7 lib's annoying things that you might want to check out.
Also for radio buttons color add
<item name="colorAccent">#000000</item>
to your style. Be careful, it's notandroid:colorAccent
butcolorAccent