Style Resource
2016-04-05 12:44
375 查看
A style resource defines the format and look for a UI. A style can be applied to an individual
within a layout file) or to an entire
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
under one
FILE LOCATION:
The filename is arbitrary. The element's
ELEMENTS:
No attributes.
attributes:
attributes:
XML file for the style (saved in
XML file that applies the style to a
in
样式资源定义的格式,并寻找一个UI。样式可以应用于单个
有关创建和应用样式的更多信息,请阅读 样式和主题。
注意:样式是使用在所提供的值引用的一个简单的资源
文件位置:
的文件名 是任意的。元素的
内容:
无属性。
属性:
属性:
对于风格的XML文件(保存在
该样式应用到一个XML文件中
View(from
within a layout file) or to an entire
Activityor 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
nameattribute (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
namewill be used as the resource ID.RESOURCE REFERENCE:In XML:
@[package:]style/style_nameSYNTAX:
<?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:
<resources>Required. This must be the root node.
No attributes.
<style>Defines a single style. Contains
<item>elements.
attributes:
nameString. Required. A name for the style, which is used as the resource ID to apply the style to a View, Activity, or application.
parentStyle resource. Reference to a style from which this style should inherit style properties.
<item>Defines a single property for the style. Must be a child of a
<style>element.
attributes:
nameAttribute resource. Required. 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!" />
样式资源定义的格式,并寻找一个UI。样式可以应用于单个
视图(从布局文件内)或整个
活动(从清单文件内)或应用程序。
有关创建和应用样式的更多信息,请阅读 样式和主题。
注意:样式是使用在所提供的值引用的一个简单的资源
名称属性(未XML文件的名称)。因此,你可以风格的资源与其他资源的简单一个XML文件中结合起来,在一个
<资源>元素。
文件位置:
RES /价值/ 文件名 的.xml
的文件名 是任意的。元素的
名字将被用作资源ID。资源引用:在XML:
@ [包:]风格/ STYLE_NAME句法:
<?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>
内容:
<资源>必选项。这必须是根节点。
无属性。
<STYLE>定义一个样式。包含
的<item>元素。
属性:
名称字符串,必需。一种用于样式,其被用作资源ID的样式应用于一个视图,活动,或应用程序的名称。
亲样式资源。参考从中这种风格要继承样式属性的样式。
<项目>定义样式的一个属性。必须是一个孩子
的<style>元素。
属性:
名称属性资源。必需。要定义的样式属性的名称,以包前缀,如果有必要(例如
机器人:文字颜色)。例:
对于风格的XML文件(保存在
RES /价值/):
<?XML版本= “1.0” 编码= “UTF-8” ?> <资源> <样式 名称= “CustomText” 父= “@风格/文本” > < 项目名称= “机器人:TEXTSIZE” > 20SP </ 项> < 项目名称= “机器人:文字颜色” >#008 </ 项目> </作风> </资源>
该样式应用到一个XML文件中
的TextView(保存在
RES /布局/):
<?xml的 世界!“ />
相关文章推荐
- Android Manifest 用法
- 什么是 GraphQL?
- Spark RDD API详解(一) Map和Reduce
- Spring Boot 开发微服务
- lwn拾遗:[sn3218 led drivers]-api解释-1
- XML 与 JSON 优劣对比
- As3.0 xml + Loader应用代码
- 一个小型js框架myJSFrame附API使用帮助
- 网马生成器 MS Internet Explorer XML Parsing Buffer Overflow Exploit (vista) 0day
- ext读取两种结构的xml的代码
- 详细分析交换机、路由器、集线器的区别和联系
- PowerShell打开或关闭光驱
- 批处理的api WMIC学习体会有感第1/2页
- 批处理 API实现文件下载的代码第1/2页
- Lua教程(十七):C API简介
- C#针对xml基本操作及保存配置文件应用实例
- Ruby程序中创建和解析XML文件的方法
- 强制删除工具 xdelbox xdelbox1.5正式版下载
- 揪出交换机端口背后“凶手”导致网速太慢