android 4.2 自定义PreferenceCategory PreferenceScreen Preference等

本文介绍了如何在Android 4.2中针对PreferenceCategory进行样式定制,包括更改title的颜色和横线颜色。通过创建自定义布局文件并在代码中设置颜色值,或者在XML中直接设置,可以实现需求。示例中提到了自定义ContactsPreferenceCategory,并展示了在包名com.android.contacts下的属性引用方式。
摘要由CSDN通过智能技术生成

需求:

4.2 原生的catagory通常 是一个title, 一条线, 通常是黑色的或白色的线, 现在有一个需求是 改变title的颜色,改变横线颜色的值。


1.  先定义这个category  的布局(布局里没有设置颜色值, 我们将在代码中设置颜色, 当然, 在 xml里也可以设置颜色):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/preference_title"
        android:layout_marginTop="1dip"
        android:layout_marginBottom="1dip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
         />

    <View
        android:id="@+id/preference_
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值