Android中Theme和style介绍
来源:互联网 发布:威客网络赚钱平台 编辑:程序博客网 时间:2024/06/06 09:46
在android开发中可以使用系统为我们提供的主题样式来设置我们的应用主题风格,我们也可以自定义主题,可以在style.xml文件中自定义如下:
<resources> <!-- 定义应用程序主题,该主题继承自系统主题:android:Theme.Light --> <style name="AppBaseTheme" parent="android:Theme.Light"> </style> <!-- Application theme.应用主题,继承自上面定义的主题:AppBaseTheme --> <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> </style></resources>
在主题定义中通过<style></style>来声明主题或样式名称,以及该父类定义的样式,这点跟css中的样式设置很类似。可以有两种方式来定义上面的继承关系:
第一种就是上面的xml中显示的,通过style的parent属性来指定父类样式。
第二种类似与css的样式继承方式:
<!-- 定义公共父类文本样式 --> <style name="CommonTextStyle"> <item name="android:textColor">#000000</item> <item name="android:textStyle">bold</item> </style> <!-- 定义标题文本样式,继承自上面的 CommonTextStyle--> <style name="CommonTextStyle.titleStyle"> <item name="android:textColor">#cccccc</item> <item name="android:textSize">18sp</item> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> </style>
在androidSDK的data\res\values\themes.xml中定义着android系统中的各种主题样式,主要样式简介:
- <style name="Theme"> android最顶级父主题,其中包含了Text styles、Button styles、Gallery attributes、Window attributes、Dialog attributes、Toast attributes、Scrollbar attributes等等很多组件的基本样式的定义。
- <style name="Theme.NoTitleBar"> NoTitleBar主题继承顶级主题,并定义窗体没有标题栏:<item name="android:windowNoTitle">true</item>
- <style name="Theme.NoTitleBar.Fullscreen">无标题、填充整个屏幕主题:<item name="android:windowFullscreen">true</item><item name="android:windowContentOverlay">@null</item>
- <style name="Theme.Light">白色主题风格
- <style name="Theme.Light.NoTitleBar">白色无标题栏主题
- <style name="Theme.Light.NoTitleBar.Fullscreen">白色、无标题栏、填充屏幕主题
- <style name="Theme.Black">黑色主题风格
- <style name="Theme.Black.NoTitleBar">黑色无标题栏主题
- <style name="Theme.Black.NoTitleBar.Fullscreen">黑色、无标题栏、填充屏幕主题
- <style name="Theme.Wallpaper">壁纸主题
- <style name="Theme.Wallpaper.NoTitleBar">无标题壁纸主题
- <style name="Theme.Wallpaper.NoTitleBar.Fullscreen">无标题、填充屏幕主题
- <style name="Theme.Translucent">半透明主题
- <style name="Theme.Translucent.NoTitleBar">半透明、无标题栏主题
- <style name="Theme.Translucent.NoTitleBar.Fullscreen">半透明、无标题栏、填充屏幕主题
- <style name="Theme.Dialog">对话框主题
等等主题,还有很多主题可以查看themes.xml查看具体详细定义。
- Android中Theme和style介绍
- android 中style和Theme
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中Theme和Style的应用
- Android中Style和Theme的使用
- android 中 style和theme的区别
- Android中Theme和Style的使用
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中style和theme的区别
- Android中style和theme的区别
- Android:Theme 和 style
- android style和theme
- Android:Style和Theme
- Android Style和Theme
- 在Hibernate中调用存储过程的示范代码
- 直接拿来用!最火前端开源项目(三)
- Unable to load configuration. - action - |Caused by: Action class [login] not found - action -
- 杭电1234-开门人和关门人
- Django学习笔记(四)
- Android中Theme和style介绍
- GOasm之Declaring ordinary uninitialised data
- cout格式输出
- socket在windows下和linux下的区别
- chukwa 0.5.0 + hbase 0.94.8 + hadoop 1.1.4 + pig 0.11.1单机伪分布配置
- 杭电1235-统计同成绩学生人数
- 获取Spring上下文
- 关于cocos2d-x中的多点触摸的问题
- A. Even Odds