Resources.Theme
Resources.Theme
extends Object
java.lang.Object | |
↳ | android.content.res.Resources.Theme |
Class Overview
This class holds the current attribute values for a particular theme. In other words, a Theme is a set of values for resource attributes; these are used in conjunction with TypedArray
to
resolve the final value for an attribute.
该类保存有当前主题的全部属性值。换句话说。该类是 resource 属性值集合;为了获得一个属性的终于的值,它常和
TypedArray 联合使用。
The Theme's attributes come into play in two ways: (1) a styled attribute can explicit reference a value in the theme through the "?themeAttribute" syntax; (2) if no value has been defined for a particular styled
attribute, as a last resort we will try to find that attribute's value in the Theme.
主题的属性值主要通过两种方式起作用:1.styled 属性能够通过 "?themeAttribute"
这样的语法明白引用一个主题的属性值。
2. styled attribute 属性没有被定义一个值。最后将在 theme 中查找改值。
You will normally use the obtainStyledAttributes(AttributeSet,
APIs to retrieve XML attributes with style and theme information applied.
int[], int, int)
您经常会使用到 obtainStyledAttributes(AttributeSet,
int[], int, int) 来检索通过 style 和 theme 应用的 xml 属性。
public TypedArray obtainStyledAttributes (AttributeSet set,
int[] attrs, int defStyleAttr, int defStyleRes)
Return a TypedArray holding the attribute values in set that are listed in attrs. In addition, if the given AttributeSet specifies a style class (through the "style" attribute),
that style will be applied on top of the base attributes it defines.
返回一个 TypedArray 来保存 attrs 列表中的属性值。另外。假设给定的 AttributeSet 通过 style
属性指定了一个 style 类,这个 style 将被应用在它定义的基础属性的最上面。
Be sure to call TypedArray.recycle()
when
you are done with the array.
当使用结束后一定要调用 TypedArray.recycle()
来回收相关的资源(比方
xml parser 等等)。
When determining the final value of a particular attribute, there are four inputs that come into play:
- Any attribute values in the given AttributeSet.
- The style resource specified in the AttributeSet (named "style").
- The default style specified by defStyleAttr and defStyleRes
- The base values in this theme.
- AttributeSet 中的不论什么属性值
- AttributeSet
中通过 style 属性指定的 style 资源 - 通过 defStyleAttr 和
defStyleRes 指定的值
- 主题中的基本值
Each of these inputs is considered in-order, with the first listed taking precedence over the following ones. In other words, if in the AttributeSet you have supplied <Button
, then the button's text will always be black, regardless of what is specified in any of the styles.
textColor="#ff000000">
上面值的优先级是自顶向下逐渐变弱的。1最高。4最弱,换句话说,1和4都指定了某个属性值,终于生效的是1中的值。
Parameters
set | The base set of attribute values. May be null. |
---|---|
attrs | The desired attributes to be retrieved. |
defStyleAttr | An attribute in the current theme that contains a reference to a style resource that supplies defaults values for the TypedArray. Can be 0 to not look for defaults. |
defStyleRes | A resource identifier of a style resource that supplies default values for the TypedArray, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults. |
Returns
- Returns a TypedArray holding an array of the attribute values. Be sure to call
TypedArray.recycle()
when
done with it.
最新文章
- objective-c第七章课后练习2
- Java StringBuilder 高性能用法总结
- MATLAB曲线绘制
- vs2015启动iis express失败
- Linux上安装JDK
- php常用的操作
- C# 读书笔记之继承与多态
- Python Django Learning Notes..
- 关于MATSIM中,如何关闭自动加载dtd的问题
- 谈谈JavaScript代码混淆
- 最短路洛谷P2384
- Redis的两种持久化方式-快照持久化和AOF持久化
- Not saving crash log because we have reached the limit for logs to store on disk.解决办法
- 开放接口/RESTful/Api服务的设计和安全方案详解
- SQL数据库索引理解与应用【转贴--收藏】
- linux git 保存用户名和密码
- PHP实现中文字符串截取无乱码
- 几个常用的SQL 时间函数
- win10 壁纸路径
- openresty + luajit