I'm searching for this for a couple of days but cannot find an answer that I can manage to get working for now.
I would like to allow the user to select in a list different themes for the whole application for day/night purposes. The issue is that I can't find a way to change the colors of the text for a ListPreference row Item textColor. Some solutions I've found are talking about using the attribute
<item name="android:textColorPrimary">@color/red_color</item>
in the style in order to set that text. However this has no effect during my tests using API 11. The results I obtained after many attempts is almost always the same: When setting different styles for the application I can change the title color for the ListPreference but not the row items text color:
Here is the screenshot :
These are the styles I am using:
<!-- Application theme. -->
<style name="AppTheme.Daylight" parent="AppBaseTheme">
<item name="android:background">@color/white</item>
<item name="android:panelBackground">@color/gray</item>
<item name="android:textColor">@color/black</item>
</style>
<style name="AppTheme.Dusk" parent="AppBaseTheme">
<item name="android:background">@color/black</item>
<item name="android:panelBackground">@color/gray</item>
<item name="android:textColor">@color/salmon</item>
</style>
<style name="AppTheme.Night" parent="AppBaseTheme">
<item name="android:background">@color/black</item>
<item name="android:panelBackground">@color/gray</item>
<item name="android:textColor">@color/red</item>
</style>
This is the display preference fragment xml file
<PreferenceCategory
android:title="@string/preference_display_settings"
android:key="display_preferences">
<ListPreference
android:key="display_mode"
android:title="@string/preference_display_settings"
android:entries="@array/preference_display_mode_available"
android:entryValues="@array/preference_display_mode_values" />
</PreferenceCategory>
Basically the question I'm asking is: - How to change the color of the entries text color in a ListPreference?
Some articles on the web are explaining how to create custom ListPreference view such as this article Custom ListPreference
Lots of thanks in advance, I'm a newbie in Android and just got out of the Coursera MOOC to create this open source application.
You can change the value for the attribute android:textColorAlertDialogListItem
like below in your theme definition.
<item name="android:textColorAlertDialogListItem">@color/white</item>
That worked for me. Good luck!!
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