# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Methods | Inherited Methods

# Resources.Theme

`public final class Resources.Theme`
`extends Object` ``

java.lang.Object
↳ | android.content.res.Resources.Theme

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.

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.

You will normally use the `obtainStyledAttributes(AttributeSet, int[], int, int)` APIs to retrieve XML attributes with style and theme information applied.

## Summary

### Public methods
`void` | `applyStyle(int resId, boolean force)` Place new attribute values into the theme.
`void` | `dump(int priority, String tag, String prefix)` Print contents of this theme out to the log.
`int[]` | `getAttributeResolutionStack(int defStyleAttr, int defStyleRes, int explicitStyleRes)` Returns the ordered list of resource ID that are considered when resolving attribute values when making an equivalent call to `obtainStyledAttributes(android.util.AttributeSet, int[], int, int)` .
`int` | `getChangingConfigurations()` Returns a bit mask of configuration changes that will impact this theme (and thus require completely reloading it).
`Drawable` | `getDrawable(int id)` Return a drawable object associated with a particular resource ID and styled for the Theme.
`int` | `getExplicitStyle(AttributeSet set)` Returns the resource ID for the style specified using `style="..."` in the `AttributeSet`'s backing XML element or `Resources#ID_NULL` otherwise if not specified or otherwise not applicable.
`Resources` | `getResources()` Returns the resources to which this theme belongs.
`TypedArray` | `obtainStyledAttributes(AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes)` Return a TypedArray holding the attribute values in set that are listed in attrs.
`TypedArray` | `obtainStyledAttributes(int[] attrs)` Return a TypedArray holding the values defined by Theme which are listed in attrs.
`TypedArray` | `obtainStyledAttributes(int resId, int[] attrs)` Return a TypedArray holding the values defined by the style resource resid which are listed in attrs.
`void` | `rebase()` Rebases the theme against the parent Resource object's current configuration by re-applying the styles passed to `applyStyle(int, boolean)`.
`boolean` | `resolveAttribute(int resid, TypedValue outValue, boolean resolveRefs)` Retrieve the value of an attribute in the Theme.
`void` | `setTo(Resources.Theme other)` Set this theme to hold the same contents as the theme other.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public methods

### applyStyle

    public void applyStyle (int resId,
                    boolean force)

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` | `int`: The resource ID of a style resource from which to obtain attribute values.
`force` | `boolean`: 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.

### dump

    public void dump (int priority,
                    String tag,
                    String prefix)

Print contents of this theme out to the log. For debugging only.

Parameters
`priority` | `int`: The log priority to use.
`tag` | `String`: The log tag to use.
`prefix` | `String`: Text to prefix each line printed.

### getAttributeResolutionStack

    public int[] getAttributeResolutionStack (int defStyleAttr,
                    int defStyleRes,
                    int explicitStyleRes)

Returns the ordered list of resource ID that are considered when resolving attribute values when making an equivalent call to `obtainStyledAttributes(android.util.AttributeSet, int[], int, int)` . The list will include a set of explicit styles (`explicitStyleRes` and it will include the default styles (`defStyleAttr` and `defStyleRes`).

Parameters
`defStyleAttr` | `int`: 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` | `int`: 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.
`explicitStyleRes` | `int`: A resource identifier of an explicit style resource.

Returns
`int[]` | ordered list of resource ID that are considered when resolving attribute values. This value cannot be `null`.

### getChangingConfigurations

    public int getChangingConfigurations ()

Returns a bit mask of configuration changes that will impact this theme (and thus require completely reloading it).

Returns
`int` | a bit mask of configuration changes, as defined by `ActivityInfo` Value is either `0` or a combination of `ActivityInfo.CONFIG_MCC`, `ActivityInfo.CONFIG_MNC`, `ActivityInfo.CONFIG_LOCALE`, `ActivityInfo.CONFIG_TOUCHSCREEN`, `ActivityInfo.CONFIG_KEYBOARD`, `ActivityInfo.CONFIG_KEYBOARD_HIDDEN`, `ActivityInfo.CONFIG_NAVIGATION`, `ActivityInfo.CONFIG_ORIENTATION`, `ActivityInfo.CONFIG_SCREEN_LAYOUT`, `ActivityInfo.CONFIG_UI_MODE`, `ActivityInfo.CONFIG_SCREEN_SIZE`, `ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE`, `ActivityInfo.CONFIG_DENSITY`, `ActivityInfo.CONFIG_LAYOUT_DIRECTION`, `ActivityInfo.CONFIG_COLOR_MODE`, and `ActivityInfo.CONFIG_FONT_SCALE`

See also:

- `ActivityInfo`

### getDrawable

    public Drawable getDrawable (int id)

Return a drawable object associated with a particular resource ID and styled for the Theme.

Parameters
`id` | `int`: The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.

Returns
`Drawable` | Drawable An object that can be used to draw this resource.

Throws
`Resources.NotFoundException` | Throws NotFoundException if the given ID does not exist.

### getExplicitStyle

    public int getExplicitStyle (AttributeSet set)

Returns the resource ID for the style specified using `style="..."` in the `AttributeSet`'s backing XML element or `Resources#ID_NULL` otherwise if not specified or otherwise not applicable.

Each `View` can have an explicit style specified in the layout file. This style is used first during the `View` attribute resolution, then if an attribute is not defined there the resource system looks at default style and theme as fallbacks.

Parameters
`set` | `AttributeSet`: The base set of attribute values. This value may be `null`.

Returns
`int` | The resource ID for the style specified using `style="..."` in the `AttributeSet`'s backing XML element or `Resources#ID_NULL` otherwise if not specified or otherwise not applicable.

### getResources

    public Resources getResources ()

Returns the resources to which this theme belongs.

Returns
`Resources` | Resources to which this theme belongs.

### obtainStyledAttributes

    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.

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:

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.

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` | `AttributeSet`: The base set of attribute values. May be null. This value may be `null`.
`attrs` | `int`: The desired attributes to be retrieved. These attribute IDs must be sorted in ascending order. This value cannot be `null`.
`defStyleAttr` | `int`: 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` | `int`: 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
`TypedArray` | Returns a TypedArray holding an array of the attribute values. Be sure to call `TypedArray.recycle()` when done with it.

See also:

- `Resources.obtainAttributes(AttributeSet, int[])`
- `obtainStyledAttributes(int[])`
- `obtainStyledAttributes(int, int[])`

### obtainStyledAttributes

    public TypedArray obtainStyledAttributes (int[] attrs)

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` | `int`: The desired attributes. These attribute IDs must be sorted in ascending order. This value cannot be `null`.

Returns
`TypedArray` | Returns a TypedArray holding an array of the attribute values. Be sure to call `TypedArray.recycle()` when done with it. This value cannot be `null`.

Throws
`Resources.NotFoundException` | Throws NotFoundException if the given ID does not exist.

See also:

- `Resources.obtainAttributes(AttributeSet, int[])`
- `obtainStyledAttributes(int, int[])`
- `obtainStyledAttributes(AttributeSet, int[], int, int)`

### obtainStyledAttributes

    public TypedArray obtainStyledAttributes (int resId,
                    int[] attrs)

Return a TypedArray holding the values defined by the style resource resid which are listed in attrs.

Be sure to call `TypedArray.recycle()` when you are done with the array.

Parameters
`resId` | `int`: The desired style resource.
`attrs` | `int`: The desired attributes in the style. These attribute IDs must be sorted in ascending order. This value cannot be `null`.

Returns
`TypedArray` | Returns a TypedArray holding an array of the attribute values. Be sure to call `TypedArray.recycle()` when done with it. This value cannot be `null`.

Throws
`Resources.NotFoundException` | Throws NotFoundException if the given ID does not exist.

See also:

- `Resources.obtainAttributes(AttributeSet, int[])`
- `obtainStyledAttributes(int[])`
- `obtainStyledAttributes(AttributeSet, int[], int, int)`

### rebase

    public void rebase ()

Rebases the theme against the parent Resource object's current configuration by re-applying the styles passed to `applyStyle(int, boolean)`.

### resolveAttribute

    public boolean resolveAttribute (int resid,
                    TypedValue outValue,
                    boolean resolveRefs)

Retrieve the value of an attribute in the Theme. The contents of outValue are ultimately filled in by `Resources#getValue`.

Parameters
`resid` | `int`: The resource identifier of the desired theme attribute.
`outValue` | `TypedValue`: Filled in with the ultimate resource value supplied by the attribute.
`resolveRefs` | `boolean`: 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` | boolean Returns true if the attribute was found and outValue is valid, else false.

### setTo

    public void setTo (Resources.Theme other)

Set this theme to hold the same contents as the theme other. If both of these themes are from the same Resources object, they will be identical after this function returns. If they are from different Resources, only the resources they have in common will be set in this theme.

Parameters
`other` | `Resources.Theme`: The existing Theme to copy from.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*