public final class

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,
int[], int, int)
 APIs to retrieve XML attributes with style and theme information applied.

您经常会使用到 obtainStyledAttributes(AttributeSet,
int[], int, int)
 来检索通过 style 和 theme 应用的 xml 属性。

public TypedArray obtainStyledAttributes (AttributeSet set,
int[] attrs, int defStyleAttr, int defStyleRes)

Added in API level 1

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:

  1. Any attribute values in the given AttributeSet.
  2. The style resource specified in the AttributeSet (named "style").
  3. The default style specified by defStyleAttr and defStyleRes
  4. The base values in this theme.

     一个属性的终于值由 4 种输入方式决定:
  1. AttributeSet 中的不论什么属性值
  2. AttributeSet
    中通过 style 属性指定的 style 资源
  3. 通过 defStyleAttr 和

    defStyleRes 指定的值

  4. 主题中的基本值

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
textColor="#ff000000">
, then the button's text will always be black, regardless of what is specified in any of the styles.

上面值的优先级是自顶向下逐渐变弱的。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.

最新文章

  1. objective-c第七章课后练习2
  2. Java StringBuilder 高性能用法总结
  3. MATLAB曲线绘制
  4. vs2015启动iis express失败
  5. Linux上安装JDK
  6. php常用的操作
  7. C# 读书笔记之继承与多态
  8. Python Django Learning Notes..
  9. 关于MATSIM中,如何关闭自动加载dtd的问题
  10. 谈谈JavaScript代码混淆
  11. 最短路洛谷P2384
  12. Redis的两种持久化方式-快照持久化和AOF持久化
  13. Not saving crash log because we have reached the limit for logs to store on disk.解决办法
  14. 开放接口/RESTful/Api服务的设计和安全方案详解
  15. SQL数据库索引理解与应用【转贴--收藏】
  16. linux git 保存用户名和密码
  17. PHP实现中文字符串截取无乱码
  18. 几个常用的SQL 时间函数
  19. win10 壁纸路径
  20. openresty + luajit

热门文章

  1. Hadoop Hive概念学习系列之hive与依赖环境的交互(二十一)
  2. 如何将工程推到github上
  3. ECharts实例开发学习笔记二——时间轴
  4. ipc (进程间通信
  5. Replacing Threads with Dispatch Queues
  6. jquery 实现 单选框点击取消
  7. API开发管理平台eoLinker AMS 4.1版本发布:加入聚合空间,发布AMS专业版等
  8. js 字符串,数组扩展
  9. Beauty of Array ZOJ - 3872(思维题)
  10. maven是干什么的?