I have installed my app in a real phone, and even though in the emulator all the texts of the preferences summaries seem to be in the same color, in the real phone the color is different (some kind of blue... but I guess it depends on the phone's model).
How can I set this color to my custom preference component? (I have implemented my own seek bar, and its summary text color is different from all the other components text color...).
Thanks!
use
Html.fromHtml("<font color=\"#B0C4DE\">This is content</font>")
to setSummaryI have figured out a way to retrieve the default color used by the Android device your application is running in. It is a bit tricky and requieres that you retrieve the color being shown from another Preference Summary View of your activity and store it in runtime.
Then you can use the same color code in other Views of other preferences, assuring that you will allways get the same color code Android assigned to the standard preferences. Here is how I did it:
My preferences activity has a normal CheckBoxPreference that I use to activate or deactivate a service. I have extended CheckBoxPreference as follows, so my extension retrieves in rutime the default color Android finally gave to the summary of that CheckBoxPreference:
In my preferences.xml I instantiate that preference as MyCheckBoxPreference instead of just CheckBoxPreference:
The MyCheckBoxPreference has to be instantiated once before retrieving the summary color with MyCheckBoxPreference.getSummaryColor().
Now you can set the color of other customized preferences from onBindView(View):
It actually works under Samsung Galaxy S. I have also tested that it doesn't break anything under the emulator.
I don't think this is possible. I am able to change the background color and the title text color, but not the summary color.
Background:
Title text:
Sorry I couldn't help more...
I found these:
android:textAppearance="?android:attr/textAppearanceLarge"
andandroid:textAppearance="?android:attr/textAppearanceSmall"
seem to do the trick.The Samsung Galaxy S phones have their own Preference layout with the text color specified for the Summary line. Even though a TextAppearance.Small is specified the textColor attribute of the layout is overriding the text appearance.
I had the same problem and I've been experimenting with my custom seekbar-preference's style. Finally these lines in
onCreateView
method ofseekBarPreference.java
show preference's summary with default text color:I use it on
preference_screen.xml
:I hope it will be useful...(and that I have written well my first answer) Regard!