Android-style&theme

概述

style 应用于 View,可以在 layout 文件中设置;

theme 本身也是 style,但应用于Activity 或 application,必须在 manifest 文件中设置;


style 的定义

自定义 style 必须放在 res/values 目录下,文件名任意,使用<resource> <style> <item> 标签


自定义 style 的继承写法

自定义 style 的继承可以通过这种写法实现,但不能继承安卓内置的 style

    <style <strong>name="CodeFont.Red"</strong>>
        <item name="android:textColor">#FF0000</item>
    </style>
 
 
    <style <strong>name="CodeFont.Red.Big"</strong>>
        <item name="android:textSize">30sp</item>
    </style>


基于系统版本自动选择 theme

通过 “res/values-vXX” 这种方法实现依据不同的系统版本应用不同的 style,并且XX及以上版本均会生效


参考

这里查看安卓系统 style, theme  R.style "/sdk/docs/reference/android/R.style.html"

这里查看 style 的所有属性 R.attr "/sdk/docs/reference/android/R.attr.html"

这里查看安卓系统 style theme 源码



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值