Style Resource

See also

  Styles and Themes

  A style resource defines the format and look for a UI. A style can be applied to an individual View (from within a layout file) or to an entire Activity or application (from within the manifest file).

For more information about creating and applying styles, please readStyles and Themes.

Note: A style is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file). As such, you can combine style resources with other simple resources in the one XML file, under one <resources> element.
FILE LOCATION:
res/values/filename.xml

The filename is arbitrary. The element's name will be used as the resource ID.

RESOURCE REFERENCE:
In XML: @[package:]style/style_name
SYNTAX:
 <?xml version="1.0" encoding="utf-8"?>
<resources>
<style
name="style_name"
parent="@[package:]style/style_to_inherit">
<item
name="[package:]style_property_name"
>style_value</item>
</style>
</resources>
ELEMENTS:
1,<resources>
  Required. This must be the root node.
  No attributes.
2,<style>
  Defines a single style. Contains <item> elements.
  

attributes:

name StringRequired. A name for the style, which is used as the resource ID to apply the style to a View, Activity, or application.
parent Style resource. Reference to a style from which this style should inherit style properties.
3,<item>
  Defines a single property for the style. Must be a child of a <style> element.
  

attributes:

name Attribute resourceRequired. The name of the style property to be defined, with a package prefix if necessary (for example android:textColor).
EXAMPLE:
XML file for the style (saved in res/values/):
 <?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomText" parent="@style/Text">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#008</item>
</style>
</resources>
XML file that applies the style to a TextView (saved in res/layout/):
 <?xml version="1.0" encoding="utf-8"?>
<EditText
style="@style/CustomText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, World!" />

Styles and Themens(5)样式文件Style.xml中各元素的含义的更多相关文章

  1. ckplayer 中的style.swf 中的 style.xml 中的修改方法

    style.swf ---- > style.zip ---- > 解压成文件夹 ---- > 打开style.xml ---- > 修改 最重要的是修改保存style.xml ...

  2. 我的Android进阶之旅------>Android资源文件string.xml中\u2026的意思

    今天看了一个string.xml文件,对其中的一行代码中包含的\u2026不是很理解,后来查阅资料后发现了其中的意思. 代码如下: <resources xmlns:xliff="ur ...

  3. dom4j修改,获取,增加xml中某个元素的属性值

    XML文件: <?xml version="1.0" encoding="UTF-8"?> <vrvscript> <item I ...

  4. web.xml中常用元素的解读

    前言 针对一个项目而言,通常会有几类XML文件需要书写. web.xml spring-context.xml spring-mvc.xml other.xml ... 不管有多少配置文件,可以肯定的 ...

  5. Maven pom.xml中的元素modules、parent、properties以及import

    前言 项目中用到了maven,而且用到的内容不像利用maven/eclipse搭建ssm(spring+spring mvc+mybatis)用的那么简单:maven的核心是pom.xml,那么我就它 ...

  6. Maven pom.xml中的元素modules、parent、properties以及import(转)

    前言 项目中用到了maven,而且用到的内容不像利用maven/eclipse搭建ssm(spring+spring mvc+mybatis)用的那么简单:maven的核心是pom.xml,那么我就它 ...

  7. SkinSoft中.vssf样式文件在VS2005中的应用(图文)

    前些天在项目中应用了皮肤控件,涉及到了(.ssk),也做了相应的记录. 但还是觉得.ssk的并不算满意,所以今天又粗略的研究了一下SkinSoft这个软件: 如题,他的作用就是自定义控件与窗体样式. ...

  8. 如何把maven文件pom.xml中的java包下载下来

    右击pom.xml文件,选择Run As-->Maven build- 在打开的页面中,如图输入"dependency:copy-dependencies",后点击" ...

  9. dom4j解析xml中指定元素下内容

    需求:XML为例如以下样式,如今我仅仅想取得timer以下的5000和60000. 解决的方法例如以下: <?xml version="1.0" encoding=" ...

随机推荐

  1. ###学习《C++ Primer》- 1

    点击查看Evernote原文. #@author: gr #@date: 2014-09-30 #@email: forgerui@gmail.com 记录读书过程中一些知识点.可能不系统,:-). ...

  2. 12天学好C语言——记录我的C语言学习之路(Day 9)

    12天学好C语言--记录我的C语言学习之路 Day 9: 函数部分告一段落,但是我们并不是把函数完全放下,因为函数无处不在,我们今后的程序仍然会大量运用到函数 //转入指针部分的学习,了解指针是什么 ...

  3. Vijos P1325桐桐的糖果计划

    > P1325桐桐的糖果计划 标签:**图结构 强连通分量** 描述 桐桐很喜欢吃棒棒糖.他家处在一大堆糖果店的附近. 但是,他们家的区域经常出现塞车.塞人等情况,这导致他不得不等到塞的车或人走 ...

  4. error C2664 转换错误汇总[转]

    vs2005提示 error C2664: “CWnd::MessageBoxW”: 不能将参数 1 从“const char [17]”转换为“LPCTSTR”. 在用vs2005编写mfc程序的时 ...

  5. 学习C++ Primer 的个人理解(七)

    类,后面还有两章是介绍有关于类的内容的.这一张依然只是个概括.但也已经将大致用法介绍完了. 重点如下: 1.成员函数的声明,必须在类的内部. 2.引用const成员函数 我们知道成员函数中有一个名为t ...

  6. Headfirst设计模式的C++实现——适配器(Adapter)

    duck.h #ifndef _DUCK_H_ #define _DUCK_H_ class DUCK { public: ; ; }; #endif mallard_duck.h #ifndef _ ...

  7. hdu 5025 Saving Tang Monk 状态压缩dp+广搜

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4092939.html 题目链接:hdu 5025 Saving Tang Monk 状态压缩 ...

  8. bootstrap和jQuery.Gantt的css冲突问题

    bootstrap是广泛使用的一个前端框架, 而jQuery.Gantt在目前也是一个很好用的用于绘制甘特图的插件.   这次在同时使用它们时,发现甘特图显示异常,如图   不加载bootstrap. ...

  9. JavaScript的语法要点 2 - Scope Chain

    前文所述,JavaScript是基于词法作用域(lexically scoped)的,所以标识符被固定在它们被定义的作用域而不是语法上或是其被调用时的作用域.即全局变量的作用域是整个程序,局部变量的作 ...

  10. 关于静态库和动态库的理解(C++)

    库的存在,是软件模块化的基础. 库存在的意义: } 库是别人写好的现有的,成熟的,可以复用的代码,你可以使用但要记得遵守许可协议.      } 现实中每个程序都要依赖很多基础的底层库,不可能每个人的 ...