Android中的 style 和 theme
通过设置 view 控件的属性,达到设置android UI的目的,如果某些 属性值复用率很高,可以考虑将属性单独声明在 style中,这样就可以达到复用的效果。
一、style
Style 概念:A style is a set of attributes that you can apply to a widget. 或者 A style is an XML resource that contains attributes that describe how a widget should look and behave. 一句话 sytle 是一组用于定义控件的属性集合。
style的定义: 以标签 <style></style>来标示,定义在 res/value 目录 文件中 根标签 <resource>,其中每个属性项目使用 <item></item>标示。可以查看系统定义的一些style:在sdk安装目录下 某个sdk版本中 :\platforms\android-19\data\res\values 的styles.xml 中,可以看到这里面属性名有以 android: 开头的,也有不以其开头的
例如:
<style name="AlertDialog">
<item name="fullDark">@android:drawable/popup_full_dark</item>
<item name="topDark">@android:drawable/popup_top_dark</item>
<item name="centerDark">@android:drawable/popup_center_dark</item>
<item name="bottomDark">@android:drawable/popup_bottom_dark</item>
<item name="fullBright">@android:drawable/popup_full_bright</item>
<item name="topBright">@android:drawable/popup_top_bright</item>
<item name="centerBright">@android:drawable/popup_center_bright</item>
<item name="bottomBright">@android:drawable/popup_bottom_bright</item>
<item name="bottomMedium">@android:drawable/popup_bottom_medium</item>
<item name="centerMedium">@android:drawable/popup_center_medium</item>
<item name="progressLayout">@android:layout/progress_dialog</item>
<item name="horizontalProgressLayout">@android:layout/alert_dialog_progress</item>
</style>
style的引用: 在控件中使用style 属性 指定需要引用的style style =“@style/stylename”
二 、theme
Theme 概念:A theme is a collection of styles. theme 是style的集合,作用于整个APP 或者 整个Activity。
theme 定义:在 res/values 目录文件中定义,以<resource>为根目录,方式与style相同。
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
theme的应用:在 Mainfest.xml 中 的 <appliaction> 或者 <activity> 标签中 使用 android:theme 指定 APP 或者某个 Activity的 theme。
使用 工程中创建的theme
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
使用系统内自带的theme
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light" >
Android中的 style 和 theme的更多相关文章
- Android 中的style和Theme的使用
说明 style和theme的定义是为了改变原有系统设定的默认窗体.字体.背景色.格式等风格而使用.其本质就是系统属性的集合.本篇主要介绍android中的style和theme的具体用法. styl ...
- 【转】说说Android中的style和theme
最近在做软件从2.3到4.0的改变的一些工作,其中涉及了一些style和theme相关的东西.上网上查了一些东西,这个一并说说.关于android中style和theme的基本使用,这里就不再赘述了, ...
- 【转】android中的Style与Theme
Android默认情况下提供了一些实用的主题样式,比如说Theme.Dialog可以让你的Activity变成一个窗口风格,而Theme.Light则让你的整个Activity具有白色的背景,而不是黑 ...
- android中的style部分属性值介绍
转自:http://blog.sina.com.cn/s/blog_70c759fd01013phv.html Android平台定义的主题样式: android:theme="@andro ...
- android中的style部分属性值介绍 --zz
Android平台定义的主题样式: android:theme="@android:style/Theme.Dialog" 将一个Activity显示为对话框模式 •andro ...
- ArcGIS Runtime SDK for Android中SimpleFillSymbol.Style样式
SimpleFillSymbol.Style样式枚举共8种: 1.BACKWARD_DIAGONAL 反对角线填充 2.CROSS 交叉线填充 3.DIAGONAL_CROSS 前后对角线填充 4.F ...
- Android中Style和Theme的使用
Style: Style是View中一些属性的集合,包括height,padding,font color,background等等,Style单独定义在xml文件中,类似与web页面中css的角色, ...
- Android中theme.xml与style.xml的区别
一.相同点 两者的定义相同.继承方式也相同 <?xml version="1.0" encoding="utf-8"?> <resources ...
- Android中style和theme的区别
在学习Xamarin android的过程中,最先开始学习的还是熟练掌握android的六大布局-LinearLayout .RelativeLayout.TableLayout.FrameLayou ...
随机推荐
- PHP 生成唯一的激活码
<? php /** * 生成永远唯一的激活码 * @return string */ function create_guid($namespace = null) { static $gui ...
- 线程相关函数(3)-pthread_detach()将某个线程设成分离态
#include <pthread.h>int pthread_detach(pthread_t tid); pthread_t tid: 分离线程的tid返回值:成功返回0,失败返回错误 ...
- spring boot热部署pom.xml配置
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- FreeRTOS 任务计数信号量,任务二值信号量,任务事件标志组,任务消息邮箱
以下基础内容转载自安富莱电子: http://forum.armfly.com/forum.php 本章节为大家讲解 FreeRTOS 计数信号量的另一种实现方式----基于任务通知(Task Not ...
- jsp页面和js代码中使用sessionScope获取session值
场景:有些实体对象可以放到HttpSession对象中,保正在一个会话期间可以随时获取这个对象的属性,例如可以将登录用户的信息写入session,以保证页面随时可以获取并显示这个用户的状态信息.下面以 ...
- 深入学习HttpClient(一)扩展额外的功能
HttpClient作为.net4.5新增的Http库除了对于async/await形式的异步支持外,还向我们展示了其强大的扩展能力. [类库的设计] 让我们先看下Httpclient的设计图: 图中 ...
- 分享8个常用的jQuery焦点图插件
现在web网页jquery应用越来越广泛,目前几乎每一个WEB项目都在使用jQuery,因为jQuery插件实在太丰富,尤其是一些图片滑块插件和jQuery焦点图插件,更是多如牛毛,很多初学者只需稍微 ...
- mysql5.5和5.6版本间的坑
mysql 5.5 int类型 设置不为null,无填充,添加新数据会自动填充0 而5.6同样的配置新建数据没值时,不让添加 5.5 datetime 不能设置默认时间(可以通过某些复杂的方式,这里说 ...
- springmvc+shiro认证框架配置
1,在web.xml中配置fiter,如下所示 <!-- shiro的filter --> <!-- shiro过虑器,DelegatingFilterProxy通过代理模式将spr ...
- 30Mybatis_mybatis和spring整合-原始dao开发
这篇文章很重要, 第一步:我们讲一下整合的思路: 我们以前要用Mybatis是需要sqlMapConfig.xml(这个配置文件需要配置dataource,以及mapper.xml文件.)sqlMap ...