Resources.Theme.ObtainStyledAttributes 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
| 名称 | 说明 |
|---|---|
| ObtainStyledAttributes(Int32[]) |
返回一个 TypedArray,其中包含 主题 定义的值,这些值列在 attrs 中。 |
| ObtainStyledAttributes(Int32, Int32[]) |
返回一个 TypedArray,其中包含样式资源定义的值,这些值 驻留 在 attrs 中。 |
| ObtainStyledAttributes(IAttributeSet, Int32[], Int32, Int32) |
返回一个 TypedArray,其中包含在 attrs 中列出的集中的属性值。 |
ObtainStyledAttributes(Int32[])
返回一个 TypedArray,其中包含 主题 定义的值,这些值列在 attrs 中。
[Android.Runtime.Register("obtainStyledAttributes", "([I)Landroid/content/res/TypedArray;", "")]
public Android.Content.Res.TypedArray ObtainStyledAttributes(int[] attrs);
[<Android.Runtime.Register("obtainStyledAttributes", "([I)Landroid/content/res/TypedArray;", "")>]
member this.ObtainStyledAttributes : int[] -> Android.Content.Res.TypedArray
参数
- attrs
- Int32[]
所需的属性。 这些属性 ID 必须按升序排序。
返回
返回一个 TypedArray,其中包含属性值的数组。
请务必在完成时调用 TypedArray#recycle() TypedArray.recycle() 。
- 特性
例外
如果给定 ID 不存在,则引发 NotFoundException。
注解
返回一个 TypedArray,其中包含 主题 定义的值,这些值列在 attrs 中。
使用数组后,请务必调用 TypedArray#recycle() TypedArray.recycle() 。
Java文档android.content.res.Resources.Theme.obtainStyledAttributes(int[])。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。
另请参阅
- <xref:Android.Content.Res.Resources.ObtainAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d)>
- <xref:Android.Content.Res.Resources.Theme.ObtainStyledAttributes(System.Int32%2c+System.Int32%5b%5d)>
- <xref:Android.Content.Res.Resources.Theme.ObtainStyledAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d%2c+System.Int32%5b%5d%2c+System.Int32%5b%5d)>
适用于
ObtainStyledAttributes(Int32, Int32[])
返回一个 TypedArray,其中包含样式资源定义的值,这些值 驻留 在 attrs 中。
[Android.Runtime.Register("obtainStyledAttributes", "(I[I)Landroid/content/res/TypedArray;", "")]
public Android.Content.Res.TypedArray ObtainStyledAttributes(int resId, int[] attrs);
[<Android.Runtime.Register("obtainStyledAttributes", "(I[I)Landroid/content/res/TypedArray;", "")>]
member this.ObtainStyledAttributes : int * int[] -> Android.Content.Res.TypedArray
参数
- resId
- Int32
所需的样式资源。
- attrs
- Int32[]
样式中所需的属性。 这些属性 ID 必须按升序排序。
返回
返回一个 TypedArray,其中包含属性值的数组。
请务必在完成时调用 TypedArray#recycle() TypedArray.recycle() 。
- 特性
例外
如果给定 ID 不存在,则引发 NotFoundException。
注解
返回一个 TypedArray,其中包含样式资源定义的值,这些值 驻留 在 attrs 中。
使用数组后,请务必调用 TypedArray#recycle() TypedArray.recycle() 。
Java文档android.content.res.Resources.Theme.obtainStyledAttributes(int, int[])。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。
另请参阅
- <xref:Android.Content.Res.Resources.ObtainAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d)>
- ObtainStyledAttributes(Int32[])
- <xref:Android.Content.Res.Resources.Theme.ObtainStyledAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d%2c+System.Int32%5b%5d%2c+System.Int32%5b%5d)>
适用于
ObtainStyledAttributes(IAttributeSet, Int32[], Int32, Int32)
返回一个 TypedArray,其中包含在 attrs 中列出的集中的属性值。
[Android.Runtime.Register("obtainStyledAttributes", "(Landroid/util/AttributeSet;[III)Landroid/content/res/TypedArray;", "")]
public Android.Content.Res.TypedArray ObtainStyledAttributes(Android.Util.IAttributeSet? set, int[] attrs, int defStyleAttr, int defStyleRes);
[<Android.Runtime.Register("obtainStyledAttributes", "(Landroid/util/AttributeSet;[III)Landroid/content/res/TypedArray;", "")>]
member this.ObtainStyledAttributes : Android.Util.IAttributeSet * int[] * int * int -> Android.Content.Res.TypedArray
参数
- set
- IAttributeSet
属性值的基集。 可以为 null。
- attrs
- Int32[]
要检索的所需属性。 这些属性 ID 必须按升序排序。
- defStyleAttr
- Int32
当前主题中的一个属性,该属性包含对样式资源的引用,该资源提供 TypedArray 的默认值。 可以是 0,无法查找默认值。
- defStyleRes
- Int32
样式资源的资源标识符,它提供 TypedArray 的默认值,仅当 defStyleAttr 为 0 或无法在主题中找到时才使用。 可以是 0,无法查找默认值。
返回
返回一个 TypedArray,其中包含属性值的数组。
请务必在完成时调用 TypedArray#recycle() TypedArray.recycle() 。
- 特性
注解
返回一个 TypedArray,其中包含在 attrs 中列出的集中的属性值。 此外,如果给定的 AttributeSet 指定样式类(通过“style”属性),该样式将应用于它定义的基属性之上。
使用数组后,请务必调用 TypedArray#recycle() TypedArray.recycle() 。
确定特定属性的最终值时,有四个输入将发挥作用:
<ol><li> 给定 AttributeSet 中的任何属性值。 <li> AttributeSet 中指定的样式资源(名为“style”)。 <li>defStyleAttr 和 defStyleRes<li> 指定的默认样式在此主题中的基本值。 </ol>
每个输入都按顺序考虑,其中第一个列出的输入优先于以下输入。 换而言之,如果在 AttributeSet 中提供了 <Button textColor="#ff000000">,则按钮的文本 将始终 为黑色,而不考虑任何样式中指定的内容。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。
另请参阅
- <xref:Android.Content.Res.Resources.ObtainAttributes(Android.Util.IAttributeSet%2c+System.Int32%5b%5d)>
- ObtainStyledAttributes(Int32[])
- <xref:Android.Content.Res.Resources.Theme.ObtainStyledAttributes(System.Int32%2c+System.Int32%5b%5d)>