Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Preference Item Summary Text Color in Android 4

I have the below sample of preference items

 <CheckBoxPreference
     android:key="chkSound"
     android:summary="Sound is Off"
     android:title="Sound" />

I use a theme in the res/values to change the Summary text color

 <style name="ThemeDarkText">
    <item name="android:textColor">#000000</item>
  </style>

And in the code I write this line

    setTheme(R.style.ThemeDarkText);

Its working fine in Android 2.1 but when I tried to run it on a different os (ex Android 4.0) It didn't change the summary text color just the title color only..!!

Any help?

like image 370
AntounG Avatar asked Aug 11 '12 21:08

AntounG


People also ask

How do I change the color of my text view?

There are two methods of changing the color of a TextView and the code for that has been given in both Java and Kotlin Programming Language for Android, so it can be done by directly adding a color attribute in the XML code or we can change it through the MainActivity File.

How do you type in different colors on Android?

Double tap the text you want to format. Tap Format, then choose a formatting option like bolding, italics, or changing the font color.

How do I change my Preferencecategory color?

Answer : You can set the EditText to have a custom transparent drawable or just use android:background="@android:color/transparent". Share your ideas with millions of readers.

How do we change a color of a text in Android Studio?

Android TextView – Text Color. TextView Text Color – To change the color of text in TextView, you can set the color in layout XML file using textColor attribute or change the color dynamically in Kotlin file using setTextColor() method.


1 Answers

I had the same problem here.

What was interesting was that the summary of Edit Preference was colored properly - red, but the Checkbox and the PreferenceScreen were white.

This is my solution:

Add this to the style.xml in your theme:

<item name="android:textColorSecondary">@color/your_color</item>
like image 113
halxinate Avatar answered Sep 20 '22 19:09

halxinate