Android 修改preferences summary 文字的颜色
参考资料:
http://stackoverflow.com/questions/4081946/android-preferences-summary-default-color
需求:
preferences summary的文字颜色通常是跟随系统的,例如黑色或白色,现需要根据不同情况改变summary的文字颜色。
解决办法:
使用Html.fromHtml("<font color=\"#B0C4DE\">This is content</font>")去设置
Summary。
例程中,fireWareVersion_str为一字符串,firmWareVersionPreference为一PreferenceScreen。
if (needUpdateFirmWare)
//firmWareVersionPreference.setSummary(fireWareVersion_str);
firmWareVersionPreference.setSummary(Html.fromHtml("<font color=\"#FF0000\">"+fireWareVersion_str+"</font>"));
else
firmWareVersionPreference.setSummary(Html.fromHtml("<font color=\"#000000\">"+fireWareVersion_str+"</font>"));
修改#FF0000,#000000 RGB颜色代码即可。
RGB颜色代码查询对照表:
http://www.114la.com/other/rgb.htm