android Theme & Style
来源:互联网 发布:淘宝添加客服怎么登陆 编辑:程序博客网 时间:2024/04/29 05:01
首先,什么是Style,什么是Theme?
- Style:是一个包含一种或者多种格式化属性的集合,我们可以将其用为一个单位用在布局XML单个元素当中。比如,我们可以定义一种风格来定义文本的字号大小和颜色,然后将其用在View元素的一个特定的实例,多用于单个控件中。
- Theme:是一个包含一种或者多种格式化属性的集合,我们可以将其为一个单位用在应用中所有的Activity当中或者应用中的某个Activity当 中。比如,我们可以定义一个Theme,它为window frame和panel 的前景和背景定义了一组颜色,并为菜单定义可文字的大小和颜色属性,可以将这个Theme应用在你程序当中所有的Activity里,多用于application,activity中。
其次,定义Styles和Themes资源的XML文档的结构
对每一个Styles和Themes,给<style>元素增加一个全局唯一的名字,也可以选择增加一个父类属性。在后边我们可以用这个名字来应用风格,而父类属性标识了当前风格是继承于哪个风格。在<style>元素内部,申明一个或者多个<item>,每一个<item>定义了一个名字属性,并且在元素内部定义了这个风格的值。
styles.xml
<resources>
<style name=”CustomStyles″>
<item name=”android:textSize”>18sp</item>
<item name=”android:textColor”>#EC9237</item>
</style>
<resources>
使用style
<TextView
style=”@styles/CustomStyles″
..../>
Themes.xml
<resources>
<style name=”CustomTheme” parent=”@android:style/Theme.Light.NoTitleBar.Fullscreen”>
<!--<item name=”android:windowNoTitle”>true</item>-->
<item name=”android:textSize”>14sp</item>
<item name=”android:textColor”>#FFFF0000</item>
</style>
</resource>
使用Theme
使用Theme
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@themes/CustomTheme"
>
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@themes/CustomTheme"
>
<activity android:name=".ActivityA"
....
android:theme="@themes/CustomTheme"
/>
/>
<activity android:name=".ActivityB"
android:theme="@android:style/Theme.Dialog"/>
</application>
android:theme="@android:style/Theme.Dialog"/>
</application>
系统提供的parent有
- android:theme & android:style
- Style android:style/Theme.Dialog
- android style & theme
- android (style&theme)
- Android Theme Style
- Android Style与Theme .
- android:style/Theme
- android Theme & Style
- android开发 Theme style
- android:style与theme
- android theme & style
- android:style/Theme
- Android:Theme 和 style
- Android自定义Theme&style
- android:style/Theme.NoTitleBar
- Android-style&theme
- android:style/Theme
- android style和theme
- 内存泄露检测之MFC
- SQUID代理服务器 导致 优酷 土豆 提示 “抱歉 此视频仅限中国内地地区播放”
- 第一时间---Windows 7 with SP1中英文原版MSDN下载汇总---原汁原味
- java的object重写equals时为什么有必要重写hashcode
- 教你如何选专业书籍 .
- android Theme & Style
- 数字电视节目码流中的PMT表分析
- 筛选法求质数(注解)
- 获得日期(今日、近三天、本周、最近6个月)
- 英语练习43 Going Camping
- Java Date类 详解
- 数据库锁表的分析与解决
- 探讨:大型视频监控平台的出路
- win7下ftp服务器配置方法