Class Resources.Theme
- Enclosing class:
Resources
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyStyle
(ResourceId resId, boolean force) Place new attribute values into the theme.void
clear()
boolean
Returns the resources to which this theme belongs.int
hashCode()
obtainStyledAttributes
(ResourceId resId, String[] attrs) Return a TypedArray holding the values defined by the resId resource which are listed in attrs.obtainStyledAttributes
(AttributeSet set, ResourceId defStyleAttr, ResourceId defStyleRes, String[] attrs) Return a TypedArray holding the attribute values in set that are listed in attrs.obtainStyledAttributes
(String[] attrs) Return a TypedArray holding the values defined by Theme which are listed in attrs.boolean
resolveAttribute
(ResourceId resId, TypedValue outValue, boolean resolveRefs) Retrieve the value of an attribute in the Theme.boolean
resolveAttribute
(String namespace, String attribute, TypedValue outValue, boolean resolveRefs) Retrieve the value of an attribute in the Theme.void
setTo
(Resources.Theme other) toString()
-
Constructor Details
-
Theme
public Theme()
-
-
Method Details
-
applyStyle
Place new attribute values into the theme. The style resource specified by resId will be retrieved from this Theme's resources, its values placed into the Theme object.The semantics of this function depends on the force argument: If false, only values that are not already defined in the theme will be copied from the system resource; otherwise, if any of the style's attributes are already defined in the theme, the current values in the theme will be overwritten.
- Parameters:
resId
- The resource ID of a style resource from which to obtain attribute values.force
- If true, values in the style resource will always be used in the theme; otherwise, they will only be used if not already defined in the theme.- Throws:
IllegalArgumentException
- if the resId is not a style or not found
-
obtainStyledAttributes
Return a TypedArray holding the values defined by Theme which are listed in attrs.Be sure to call
TypedArray.recycle()
when you are done with the array.- Parameters:
attrs
- The desired attributes to be retrieved. SeeStyleableRes
for requirements.- Returns:
- Returns a TypedArray holding an array of the attribute values.
Be sure to call
TypedArray.recycle()
when done with it. - See Also:
-
obtainStyledAttributes
@NonNull public TypedArray obtainStyledAttributes(@Nullable @StyleRes ResourceId resId, @NonNull @StyleableRes String[] attrs) Return a TypedArray holding the values defined by the resId resource which are listed in attrs.Be sure to call
TypedArray.recycle()
when you are done with the array.- Parameters:
resId
- The desired style resource.attrs
- The desired attributes to be retrieved. SeeStyleableRes
for requirements.- Returns:
- Returns a TypedArray holding an array of the attribute values.
Be sure to call
TypedArray.recycle()
when done with it. - See Also:
-
obtainStyledAttributes
@NonNull public TypedArray obtainStyledAttributes(@Nullable AttributeSet set, @Nullable @AttrRes ResourceId defStyleAttr, @Nullable @StyleRes ResourceId defStyleRes, @NonNull @StyleableRes String[] attrs) 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.Be sure to call
TypedArray.recycle()
when you are done with the array.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.
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.- Parameters:
set
- The base set of attribute values. May be null.defStyleAttr
- An attribute in the current theme that contains a reference to a style resource that supplies defaults values for the TypedArray. Can be null 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 null or can not be found in the theme. Can be null to not look for defaults.attrs
- The desired attributes to be retrieved. SeeStyleableRes
for requirements.- Returns:
- Returns a TypedArray holding an array of the attribute values.
Be sure to call
TypedArray.recycle()
when done with it. - See Also:
-
resolveAttribute
public boolean resolveAttribute(@NonNull @AttrRes ResourceId resId, @NonNull TypedValue outValue, boolean resolveRefs) Retrieve the value of an attribute in the Theme. The contents of outValue are ultimately filled in byResources.getValue(icyllis.modernui.resources.ResourceId, icyllis.modernui.resources.TypedValue, boolean)
.- Parameters:
resId
- The resource identifier of the desired theme attribute.outValue
- Filled in with the ultimate resource value supplied by the attribute.resolveRefs
- If true, resource references will be walked; if false, outValue may be a TYPE_REFERENCE. In either case, it will never be a TYPE_ATTRIBUTE.- Returns:
- boolean Returns true if the attribute was found and outValue is valid, else false.
-
resolveAttribute
public boolean resolveAttribute(@NonNull String namespace, @NonNull String attribute, @NonNull TypedValue outValue, boolean resolveRefs) Retrieve the value of an attribute in the Theme. The contents of outValue are ultimately filled in byResources.getValue(icyllis.modernui.resources.ResourceId, icyllis.modernui.resources.TypedValue, boolean)
.- Parameters:
outValue
- Filled in with the ultimate resource value supplied by the attribute.resolveRefs
- If true, resource references will be walked; if false, outValue may be a TYPE_REFERENCE. In either case, it will never be a TYPE_ATTRIBUTE.- Returns:
- boolean Returns true if the attribute was found and outValue is valid, else false.
-
getResources
Returns the resources to which this theme belongs.- Returns:
- Resources to which this theme belongs.
-
setTo
-
clear
public void clear() -
hashCode
public int hashCode() -
equals
-
toString
-