以前没怎么关注过PreferenceActivity的一些用法只是简单了解下,然后刚好今天遇到了某个机型上出现了问题:我明明设置的是黑色的字体,在这个机器上却是白色的,然后各种摸索得出了个推论,页面的字体颜色什么的,可能是更随系统来的,受系统调控:

我是这么写的,

android:defaultValue="true"

android:key="weather_use_metric"

android:textColor="@color/black"

android:title="@string/weather_use_metric" />

问题出现 了那没办法,只能想办法改了,好在现在学会了面向google编程,然后搜的一下,找到了个解决方案,先上怎么解决,然后再说为什么这么干。首先建个layout ,名字随便取(我取名custom_preferece_layout.xml),内容如下:

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:minHeight="?android:attr/listPreferredItemHeight"

android:gravity="center_vertical"

android:paddingRight="?android:attr/scrollbarSize">

android:layout_height="wrap_content" android:layout_marginLeft="15dip"

android:layout_marginRight="6dip"

android:layout_marginTop="6dip"

android:layout_marginBottom="6dip"

android:layout_weight="1">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:singleLine="true"

android:textAppearance="?android:attr/textAppearanceLarge"

android:ellipsize="marquee" android:fadingEdge="horizontal"

android:textColor="@color/black" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@android:id/title"

android:layout_alignLeft="@android:id/title"

android:textAppearance="?android:attr/textAppearanceSmall"

android:maxLines="4" />

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:gravity="center_vertical" android:orientation="vertical" />

在这个布局中修改title,sunmmary的颜色就可以了。

然后再CheckBoxPreference 中加一句:

android:defaultValue="true"

android:key="weather_use_metric"

android:layout="@layout/custom_preferece_layout"

android:textColor="@color/black"

/>

然后,就解决了这个问题,那为什么这么搞呢?进入CheckBoxPreference 顶层父类Preference中看,看到构造中的注释了:

QQ截图20161110175559.png

这玩意默认的控制了样式,然后再往下看到一个方法:

QQ截图20161110175911.png

他说大部分情况足够用了,但是这不是出来问题么,于是到android的values中的attr下找,

Paste_Image.png

嗯很贴心,行数都截出来了。顶层默认实现了个布局,在CheckBoxPreference的onBindView方法中出现了个id和一个方法:

QQ截图20161110181103.png

id点进去能找到个布局,然后再父类TwoStatePreference中可以看到这个方法里面写了什么,注意看上面的布局控件的id,你没看错,就是覆盖了preference_material.xml 中的布局:

QQ截图20161110181315.png

android preference-headers 字体颜色,如何修改CheckBoxPreference 中title ,summary字体的颜色...相关推荐

  1. android preference-headers 字体颜色,android 批改preference中view属性(title,summary字体颜色等)...

    当前位置:我的异常网» Android » android 批改preference中view属性(title,summary字 android 批改preference中view属性(title,s ...

  2. 教你如何修改地图中的默认字体和大小

    觉得默认地图中的字体太小?没关系,你可以通过BIGEMAP下载到大字体地图,自定义字体(宋体.雅黑等等).字号大小和颜色等,支持电子地图.卫星地图,如图 第一步,下载电子地图的大字体可直接选择地图源为 ...

  3. macOS Mojave Version 10.14 新系统字体问题和修改MAC中Launchpad启动器图标行列的数量

    原文:https://www.jianshu.com/p/c4a490775535 原文: macOS Mojave Version 10.14 新系统字体问题 and other 补充: 未知开发者 ...

  4. word修改公式中的部分字体

    有时候只想修改word公式中的部分字体大小,方法是先将公式变成普通文本格式再进行修改.

  5. Qt MVD框架下修改视图中数据项/标题的背景颜色说明(Qt 5.10.1)

    在不利用QSS的情况下,如果想修改MVD中视图的某个数据项的背景颜色,则可以: QVariant YourModel::data(const QModelIndex &index, int r ...

  6. 统一修改word中的英文字体

    转自  https://jingyan.baidu.com/article/3a2f7c2e62835e26afd61129.html 我们常常会用word浏览各种文件,有的时候遇到一些中英文资料,我 ...

  7. 如何修改typora中代码块字体大小的方法

    如何修改typora中代码块内的字体大小 typora是一款非常好用的Markdown文档编辑器,但是自己在使用过程中总觉得默认的代码块字体有些偏小,在复习时不方便阅读笔记,今天来帮助有相同需求的朋友 ...

  8. html5 在线字体库,网络字体@font-face,如何处理网页中的特殊字体?

    网络字体@font-face 如何处理网页中的特殊字体 HTML5学堂:随着网页的发展,网页中出现了越来越多的字体种类,网页自带的微软雅黑.宋体.黑体已经越来越难以满足设计的需要,那么,如何在网站中使 ...

  9. 怎么调大matlab界面字体,【答疑】Matlab中怎么更改字体的大小? - 羽兔网问答

    个人电脑中现在有两个Matlab版本,略有不同,分别说明. 1.首先说R2009b版本,具体版本号如图所示: 第一步:File--Preferences,如下图所示:(这一步两个版本是一样子的) 第二 ...

  10. html中的字体选择,谈谈Web标准设计中的常用字体和选用原则

    浏览器中展示网页文字内容时,文字字体都会按照设计师在css中定义的字体族的顺序来进行显示. 什么是字体族?字体族就是你在css代码中看到"font-family"的代码内的一类字体 ...

最新文章

  1. python操作mysql(二)
  2. 2月中国域名总量平稳回升 净增长量逾10.3万个
  3. python事件处理函数_事件驱动的简明讲解(python实现)
  4. android 上传到了maven,但是报错找不到jar
  5. 11.23关于微信JSAPI缺少参数的问题解决
  6. RHCE课程-RH253Linux服务器架设笔记三-Samba服务器配置(1)
  7. php pecl memcached,php – 安装PECL Memcached错误
  8. 远程协助TeamView软件 轻松控制计算机
  9. hdu 1564 Play a game
  10. mysql hp ux_hp ux apa 切换
  11. php对角线数组代码,php数组内容查找代码
  12. [bbk2228] 第41集 - Chapter 11-SQL Statement Tuning(00)
  13. 2021李宏毅机器学习课程笔记——Adversarial Attack
  14. 绿盟漏洞扫描工具_IDC盘点2020上半年中国安全市场绿盟科技再获响应和编排能力认可...
  15. 支持傲腾技术的服务器主板,G4560可以用傲腾内存么
  16. Tbase基础积累一
  17. C/C++和Lua混合编程
  18. matlab中dot是什么,matlab中ddot是什么
  19. locality sensitive hashing(LSH)原理和具体实现
  20. centos7通过yum安装nginx以及其简单配置使用

热门文章

  1. windows下无npcap驱动导致golang获取网卡失败问题
  2. 基于IM实现直播礼物效果
  3. 结合LayoutIt学习Bootstrap的探索
  4. 程序员绩效考核工作汇报
  5. linux平台使用doxygen生成项目文档
  6. 2006年考研数学一解析pdf
  7. ubuntu下ROS使用罗技C525/270等摄像头(驱动安装)
  8. android自定义图标下载,Android使用IconFont矢量图标库
  9. MySQL查询数据库日志的查询
  10. notepad黑色主题