概述
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"
本文深入探讨了Android中自定义style与theme的应用方法,包括如何在布局文件中设置style,如何在manifest文件中应用theme,以及如何根据不同系统版本自动选择style。详细介绍了style的定义、继承以及如何在不同版本的Android系统中实现自定义风格。
2357

被折叠的 条评论
为什么被折叠?



