通过设置 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的更多相关文章

  1. Android 中的style和Theme的使用

    说明 style和theme的定义是为了改变原有系统设定的默认窗体.字体.背景色.格式等风格而使用.其本质就是系统属性的集合.本篇主要介绍android中的style和theme的具体用法. styl ...

  2. 【转】说说Android中的style和theme

    最近在做软件从2.3到4.0的改变的一些工作,其中涉及了一些style和theme相关的东西.上网上查了一些东西,这个一并说说.关于android中style和theme的基本使用,这里就不再赘述了, ...

  3. 【转】android中的Style与Theme

    Android默认情况下提供了一些实用的主题样式,比如说Theme.Dialog可以让你的Activity变成一个窗口风格,而Theme.Light则让你的整个Activity具有白色的背景,而不是黑 ...

  4. android中的style部分属性值介绍

    转自:http://blog.sina.com.cn/s/blog_70c759fd01013phv.html Android平台定义的主题样式: android:theme="@andro ...

  5. android中的style部分属性值介绍 --zz

    Android平台定义的主题样式: android:theme="@android:style/Theme.Dialog"   将一个Activity显示为对话框模式 •andro ...

  6. ArcGIS Runtime SDK for Android中SimpleFillSymbol.Style样式

    SimpleFillSymbol.Style样式枚举共8种: 1.BACKWARD_DIAGONAL 反对角线填充 2.CROSS 交叉线填充 3.DIAGONAL_CROSS 前后对角线填充 4.F ...

  7. Android中Style和Theme的使用

    Style: Style是View中一些属性的集合,包括height,padding,font color,background等等,Style单独定义在xml文件中,类似与web页面中css的角色, ...

  8. Android中theme.xml与style.xml的区别

    一.相同点 两者的定义相同.继承方式也相同 <?xml version="1.0" encoding="utf-8"?> <resources ...

  9. Android中style和theme的区别

    在学习Xamarin android的过程中,最先开始学习的还是熟练掌握android的六大布局-LinearLayout .RelativeLayout.TableLayout.FrameLayou ...

随机推荐

  1. U盘 格式化 ext3 ext4

    [root@ok Desktop]# mkfs.ext3 /dev/sdc mke2fs 1.41.12 (17-May-2010) /dev/sdc is entire device, not ju ...

  2. ubutun:从共享文件夹拷贝文件尽量使用cp命令而不是CTRL+C/V

    为了方便,VBOX安装的Ubuntu,并在硬盘上创建了一个与Windows的共享文件夹sharefolder方便在两个系统之间传文件 但是经常发现的问题就是从sharefolder中拷贝文件到ubun ...

  3. jquery 给表格tbody t 加事件

    jquery给所有td加事件 $('#erji_list_table').on('click','td', function(){ $('#yuan_content').slideToggle(&qu ...

  4. FreeRTOS 任务优先级分配方案

    任务优先级说明下面对 FreeRTOS 优先级相关的几个重要知识点进行下说明,这些知识点在以后的使用中务必要掌握牢固.  FreeRTOS 中任务的最高优先级是通过 FreeRTOSConfig.h ...

  5. 如何找到文件的家-打开文件对话框openFileDialog

    private void button1_Click(object sender, EventArgs e) { openFileDialog1.Filter = "*.txt|*.txt& ...

  6. centos6.5 系统上升级2.6.6到2.7.12

    因开发需要,今天把CentOS 6.4自带的Python2.6.6升级到了Python2.7.3.按照如下步骤进行升级 1.查看当前系统python的版本 python -V 2.下载2.7.3版本的 ...

  7. GUI 即人机交互图形化用户界面设计

    GUI 即人机交互图形化用户界面设计.纵观国际相关产业在图形化用户界面设计方面的发展现状,许多国际知名公司早已意识到 GUI 在产品方面产生的强大增值功能,以及带动的巨大市场价值,因此在公司内部设立了 ...

  8. $ -----JavaScript 中美元符号 $ 的作用

    JavaScript 中美元符号 $ 是什么 1.首先可以用来表示变量,比如变量 var s='asdsd'或var $s='asdasd'; 2.在正则表达式中,它可以匹配结尾:/sa$/.test ...

  9. iScroll框架解析——Android 设备页面内 div(容器,非页面)overflow:scroll; 失效解决(转)

    移动平台的活,兼容问题超多,今儿又遇到一个.客户要求在弹出层容器内显示内容,但内容条数过多,容器显示滚动条.按说是So easy,容器设死宽.高,CSS加属性 overflow:scroll; -we ...

  10. 返回flag

    //修改前namespace CleanCSharp.Errors.Dirty { public class SomeClass { public int DoSomeProcess(int? id) ...