How can I set the android preference summary text color? How can I set the android preference summary text color? android android

How can I set the android preference summary text color?


OK what I ended up doing was using a Spannable. This takes the color as an integer.

Spannable summary = new SpannableString("Currently This Color");summary.setSpan(new ForegroundColorSpan(color), 0, summary.length(), 0);preference.setSummary(summary);


Use Html.fromHtml to style your text.

mPodFolderPref.setTitle(Html.fromHtml("<font color='red'>" +  mPodFolderPref.getTitle() + "</font>"));mPodFolderPref.setSummary(Html.fromHtml("<font color='red'>" +  mPodFolderPref.getSummary() + "</font>"));

Html.fromHtml can do a lot for you.


A bit late, but I found useful to write these self-contained methods:

private void setColorPreferencesTitle(EditTextPreference textPref, int color) {    CharSequence cs     = (CharSequence) textPref.getTitle();    String plainTitle   = cs.subSequence(0, cs.length()).toString();    Spannable coloredTitle = new SpannableString (plainTitle);    coloredTitle.setSpan( new ForegroundColorSpan(color), 0, coloredTitle.length(), 0 );    textPref.setTitle(coloredTitle);}private void resetColorPreferencesTitle(EditTextPreference textPref) {    CharSequence cs     = (CharSequence) textPref.getTitle();    String plainTitle   = cs.subSequence(0, cs.length()).toString();    textPref.setTitle(plainTitle);}