android:theme="@style,NOTE:Android Styles and Themes的一些需要注意的小细节

1. 继承: 在运用系统自带的风格时只想改变其中一些小的方面,当然,我们可以直接在布局文件中控件的属性里重写这个属性即可。因为在布局文件中定义的属性的优先级>我们在style中定义的属性。

<style name="GreenText" parent="@android:style/TextAppearance">
        <item name="android:textColor">#00FF00</item>
</style>

若是继承自己定义的style时可以使用下面格式,继承于CodeFont.但不适用于继承系统自带的style

<style name="CodeFont.Red">
        <item name="android:textColor">#FF0000</item>
</style>

2.  style内容:可以上Android developer查找特定类的XML attributes,还有些属性是不属于任何view,只属于window的.

However, if you apply a style to a View that does not support all of the style properties, the View will apply only those properties that are supported and simply ignore the others.

你所定义的style,并不一定适用于所有的视图,有些属性试图并不支持,这个时候,视图将只会运用它所支持的属性,忽略掉剩下的属性.

3. 应用style:

<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Light">
    <item name="android:windowBackground">@color/custom_theme_color</item>
    <item name="android:colorBackground">@color/custom_theme_color</item>
</style>

(Note that the color needs to supplied as a separate resource here because the android:windowBackgroundattribute only supports a reference to another resource; unlike android:colorBackground, it can not be given a color literal.)

注意到android:windowBackground只支持对另一资源的引用,这与android:colorBackground不一样.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值