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

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

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

www.myexceptions.net  网友分享于:2013-03-26  浏览:286次

android 修改preference中view属性(title,summary字体颜色等)

有些时候,我们并不需要系统给我们的这么单调的ui,我们通常会修改一些属性,比如 view的背景,字体的属性等,那么这个时候有两种选择:

1.针对单个应用程序,定义一个cutom的layout,当然这个 layout跟系统的layout元素要一致(否则你怎么改呢?),然后在preference.xml(文件名你自己随便取)android:layout添加你定一个 的layout就可以了。

2.针对整个android系统,修改preference 相关的属性,那么所有的用到PreferenceActivity的界面都会相应的改变。这里只需要修改相应的系统layout文件(在 framework/base/core/res/res/layout),比如preference_category.xml等。

1.先说说地一种吧,比较常用到的。

首先,定义你的layout文件,这个layoutn你直接到framework拷下来,这里标记为custom_preference.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="#475ad7"/>

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:textColor="#5ad747"/>

android:layout_width="wrap_content" android:layout_height="match_parent"

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

然后,你在些preference.xml文件的时候,应用到这个layout文件。

android:title="checkbox_title"

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值