# Resources.Theme

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Theme

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/content/res/Resources.Theme "View this page in Java")  

```
class Theme
```

|---|----------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                             ||
| ↳ | [android.content.res.Resources.Theme](https://developer.android.com/reference/kotlin/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](https://developer.android.com/reference/kotlin/android/content/res/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 APIs to retrieve XML attributes with style and theme information applied.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ||
|------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                         | [applyStyle](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#applyStyle(kotlin.Int,%20kotlin.Boolean))`(`resId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `force:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Place new attribute values into the theme.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                         | [dump](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#dump(kotlin.Int,%20kotlin.String,%20kotlin.String))`(`priority:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `tag:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `prefix:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Print contents of this theme out to the log.                                                                                                                                                                                                                                                                                                                                                                                         |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                   | [equals](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` Indicates whether some other object is "equal to" this one.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)                | [getAttributeResolutionStack](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#getAttributeResolutionStack(kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`defStyleAttr:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `defStyleRes:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `explicitStyleRes:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` 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)](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(android.util.AttributeSet,%20kotlin.IntArray,%20kotlin.Int,%20kotlin.Int)). |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [getChangingConfigurations](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#getChangingConfigurations())`()` Returns a bit mask of configuration changes that will impact this theme (and thus require completely reloading it).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.html#)! | [getDrawable](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#getDrawable(kotlin.Int))`(`id:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Return a drawable object associated with a particular resource ID and styled for the Theme.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [getExplicitStyle](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#getExplicitStyle(android.util.AttributeSet))`(`set:` `[AttributeSet](https://developer.android.com/reference/kotlin/android/util/AttributeSet.html#)?`)` Returns the resource ID for the style specified using`style="..."`in the[AttributeSet](https://developer.android.com/reference/kotlin/android/util/AttributeSet.html#)'s backing XML element or[Resources.ID_NULL](https://developer.android.com/reference/kotlin/android/content/res/Resources#ID_NULL:kotlin.Int)otherwise if not specified or otherwise not applicable.                                                                                                                                                                                                                                 |
| [Resources](https://developer.android.com/reference/kotlin/android/content/res/Resources)!           | [getResources](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#getResources())`()` Returns the resources to which this theme belongs.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                           | [hashCode](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#hashCode())`()` <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [TypedArray](https://developer.android.com/reference/kotlin/android/content/res/TypedArray)          | [obtainStyledAttributes](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(android.util.AttributeSet,%20kotlin.IntArray,%20kotlin.Int,%20kotlin.Int))`(`set:` `[AttributeSet](https://developer.android.com/reference/kotlin/android/util/AttributeSet.html#)?`, `attrs:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)`, `defStyleAttr:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `defStyleRes:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Return a TypedArray holding the attribute values in set that are listed in attrs.                                                                                                                                                                  |
| [TypedArray](https://developer.android.com/reference/kotlin/android/content/res/TypedArray)          | [obtainStyledAttributes](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(kotlin.Int,%20kotlin.IntArray))`(`resId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `attrs:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)`)` Return a TypedArray holding the values defined by the style resource resid which are listed in attrs.                                                                                                                                                                                                                                                                                                                                                                                                       |
| [TypedArray](https://developer.android.com/reference/kotlin/android/content/res/TypedArray)          | [obtainStyledAttributes](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(kotlin.IntArray))`(`attrs:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)`)` Return a TypedArray holding the values defined by Theme which are listed in attrs.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                         | [rebase](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#rebase())`()` Rebases the theme against the parent Resource object's current configuration by re-applying the styles passed to[applyStyle(int,boolean)](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#applyStyle(kotlin.Int,%20kotlin.Boolean)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                   | [resolveAttribute](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#resolveAttribute(kotlin.Int,%20android.util.TypedValue,%20kotlin.Boolean))`(`resid:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `outValue:` `[TypedValue](https://developer.android.com/reference/kotlin/android/util/TypedValue.html#)!`, `resolveRefs:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Retrieve the value of an attribute in the Theme.                                                                                                                                                                                                                                                                                                                                |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                         | [setTo](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#setTo(android.content.res.Resources.Theme))`(`other:` `[Resources.Theme](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#)!`)` Set this theme to hold the same contents as the theme other.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                     | [toString](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#toString())`()` <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

## Public methods

### applyStyle

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun applyStyle(
    resId: Int, 
    force: Boolean
): Unit
```

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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The resource ID of a style resource from which to obtain attribute values.                                                                             |
| `force` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):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

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun dump(
    priority: Int, 
    tag: String!, 
    prefix: String!
): Unit
```

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

|                                                           Parameters                                                            ||
|------------|---------------------------------------------------------------------------------------------------------------------|
| `priority` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The log priority to use.                 |
| `tag`      | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The log tag to use.               |
| `prefix`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:Text to prefix each line printed. |

### equals

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun equals(other: Any?): Boolean
```

Indicates whether some other object is "equal to" this one.

The`equals`method implements an equivalence relation on non-null object references:

- It is*reflexive* : for any non-null reference value`x`,`x.equals(x)`should return`true`.
- It is*symmetric* : for any non-null reference values`x`and`y`,`x.equals(y)`should return`true`if and only if`y.equals(x)`returns`true`.
- It is*transitive* : for any non-null reference values`x`,`y`, and`z`, if`x.equals(y)`returns`true`and`y.equals(z)`returns`true`, then`x.equals(z)`should return`true`.
- It is*consistent* : for any non-null reference values`x`and`y`, multiple invocations of`x.equals(y)`consistently return`true`or consistently return`false`, provided no information used in`equals`comparisons on the objects is modified.
- For any non-null reference value`x`,`x.equals(null)`should return`false`.

An equivalence relation partitions the elements it operates on into*equivalence classes*; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

|                     Parameters                     ||
|-------|---------------------------------------------|
| `obj` | the reference object with which to compare. |
| `o`   | This value may be`null`.                    |

|                                                                           Return                                                                           ||
|------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this object is the same as the obj argument;`false`otherwise. |

### getAttributeResolutionStack

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAttributeResolutionStack(
    defStyleAttr: Int, 
    defStyleRes: Int, 
    explicitStyleRes: Int
): IntArray
```

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)](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(android.util.AttributeSet,%20kotlin.IntArray,%20kotlin.Int,%20kotlin.Int)). The list will include a set of explicit styles (`explicitStyleRes`and it will include the default styles (`defStyleAttr`and`defStyleRes`).

|                                                                                                                                          Parameters                                                                                                                                           ||
|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `defStyleAttr`     | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):A resource identifier of an explicit style resource.                                                                                                                                           |

|                                                                                               Return                                                                                                ||
|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
| [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html) | ordered list of resource ID that are considered when resolving attribute values. This value cannot be`null`. |

### getChangingConfigurations

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getChangingConfigurations(): Int
```

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

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Return                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ||
|----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a bit mask of configuration changes, as defined by[ActivityInfo](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#)Value is either`0`or a combination of[android.content.pm.ActivityInfo#CONFIG_MCC](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_MCC:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_MNC](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_MNC:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_LOCALE](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_LOCALE:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_TOUCHSCREEN](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_TOUCHSCREEN:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_KEYBOARD](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_KEYBOARD:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_KEYBOARD_HIDDEN](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_KEYBOARD_HIDDEN:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_NAVIGATION](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_NAVIGATION:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_ORIENTATION](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_ORIENTATION:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_SCREEN_LAYOUT](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_SCREEN_LAYOUT:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_UI_MODE](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_UI_MODE:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_SCREEN_SIZE:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_SMALLEST_SCREEN_SIZE:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_DENSITY](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_DENSITY:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_LAYOUT_DIRECTION](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_LAYOUT_DIRECTION:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_COLOR_MODE](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_COLOR_MODE:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_FONT_SCALE](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_FONT_SCALE:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_GRAMMATICAL_GENDER](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_GRAMMATICAL_GENDER:kotlin.Int),[android.content.pm.ActivityInfo#CONFIG_FONT_WEIGHT_ADJUSTMENT](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_FONT_WEIGHT_ADJUSTMENT:kotlin.Int), android.content.pm.ActivityInfo.CONFIG_WINDOW_CONFIGURATION,[android.content.pm.ActivityInfo#CONFIG_ASSETS_PATHS](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_ASSETS_PATHS:kotlin.Int), and[android.content.pm.ActivityInfo#CONFIG_RESOURCES_UNUSED](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#CONFIG_RESOURCES_UNUSED:kotlin.Int) |

**See Also**

- [android.content.pm.ActivityInfo](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#)  

### getDrawable

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getDrawable(id: Int): Drawable!
```

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

|                                                                                                                     Parameters                                                                                                                     ||
|------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):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. |

|                                                                              Return                                                                              ||
|------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.html#)! | Drawable An object that can be used to draw this resource. |

|                                                 Exceptions                                                  ||
|---------------------------------------------------|----------------------------------------------------------|
| `android.content.res.Resources.NotFoundException` | Throws NotFoundException if the given ID does not exist. |

### getExplicitStyle

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getExplicitStyle(set: AttributeSet?): Int
```

Returns the resource ID for the style specified using`style="..."`in the[AttributeSet](https://developer.android.com/reference/kotlin/android/util/AttributeSet.html#)'s backing XML element or[Resources.ID_NULL](https://developer.android.com/reference/kotlin/android/content/res/Resources#ID_NULL:kotlin.Int)otherwise if not specified or otherwise not applicable.

Each[android.view.View](https://developer.android.com/reference/kotlin/android/view/View.html#)can have an explicit style specified in the layout file. This style is used first during the[android.view.View](https://developer.android.com/reference/kotlin/android/view/View.html#)attribute resolution, then if an attribute is not defined there the resource system looks at default style and theme as fallbacks.

|                                                                            Parameters                                                                             ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `set` | [AttributeSet](https://developer.android.com/reference/kotlin/android/util/AttributeSet.html#)?:The base set of attribute values. This value may be`null`. |

|                                                                                                                                                                                                                     Return                                                                                                                                                                                                                     ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The resource ID for the style specified using`style="..."`in the[AttributeSet](https://developer.android.com/reference/kotlin/android/util/AttributeSet.html#)'s backing XML element or[Resources.ID_NULL](https://developer.android.com/reference/kotlin/android/content/res/Resources#ID_NULL:kotlin.Int)otherwise if not specified or otherwise not applicable. |

### getResources

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getResources(): Resources!
```

Returns the resources to which this theme belongs.

|                                                               Return                                                               ||
|--------------------------------------------------------------------------------------------|----------------------------------------|
| [Resources](https://developer.android.com/reference/kotlin/android/content/res/Resources)! | Resources to which this theme belongs. |

### hashCode

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun hashCode(): Int
```

|                                                     Return                                                     ||
|----------------------------------------------------------------------------|------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a hash code value for this object. |

### obtainStyledAttributes

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun obtainStyledAttributes(
    set: AttributeSet?, 
    attrs: IntArray, 
    defStyleAttr: Int, 
    defStyleRes: Int
): TypedArray
```

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()](https://developer.android.com/reference/kotlin/android/content/res/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](https://developer.android.com/reference/kotlin/android/util/AttributeSet.html#)?:The base set of attribute values. May be null.                                                                                                                            |
| `attrs`        | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html):The desired attributes to be retrieved. These attribute IDs must be sorted in ascending order. This value cannot be`null`.                                                          |
| `defStyleAttr` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):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. |

|                                                                                                                                                                  Return                                                                                                                                                                  ||
|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TypedArray](https://developer.android.com/reference/kotlin/android/content/res/TypedArray) | Returns a TypedArray holding an array of the attribute values. Be sure to call[TypedArray.recycle()](https://developer.android.com/reference/kotlin/android/content/res/TypedArray#recycle())when done with it. This value cannot be`null`. |

**See Also**

- [Resources#obtainAttributes](https://developer.android.com/reference/kotlin/android/content/res/Resources#obtainAttributes(android.util.AttributeSet,%20kotlin.IntArray))
- [#obtainStyledAttributes(int[])](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(kotlin.IntArray))
- [#obtainStyledAttributes(int, int[])](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(kotlin.Int,%20kotlin.IntArray))  

### obtainStyledAttributes

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun obtainStyledAttributes(
    resId: Int, 
    attrs: IntArray
): TypedArray
```

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

Be sure to call[TypedArray.recycle()](https://developer.android.com/reference/kotlin/android/content/res/TypedArray#recycle())when you are done with the array.

|                                                                                                       Parameters                                                                                                       ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The desired style resource.                                                                                                        |
| `attrs` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html):The desired attributes in the style. These attribute IDs must be sorted in ascending order. This value cannot be`null`. |

|                                                                                                                                                                  Return                                                                                                                                                                  ||
|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TypedArray](https://developer.android.com/reference/kotlin/android/content/res/TypedArray) | Returns a TypedArray holding an array of the attribute values. Be sure to call[TypedArray.recycle()](https://developer.android.com/reference/kotlin/android/content/res/TypedArray#recycle())when done with it. This value cannot be`null`. |

|                                                 Exceptions                                                  ||
|---------------------------------------------------|----------------------------------------------------------|
| `android.content.res.Resources.NotFoundException` | Throws NotFoundException if the given ID does not exist. |

**See Also**

- [Resources#obtainAttributes](https://developer.android.com/reference/kotlin/android/content/res/Resources#obtainAttributes(android.util.AttributeSet,%20kotlin.IntArray))
- [#obtainStyledAttributes(int[])](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(kotlin.IntArray))
- [#obtainStyledAttributes(AttributeSet, int[], int, int)](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(android.util.AttributeSet,%20kotlin.IntArray,%20kotlin.Int,%20kotlin.Int))  

### obtainStyledAttributes

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun obtainStyledAttributes(attrs: IntArray): TypedArray
```

Return a TypedArray holding the values defined by Theme which are listed in attrs.

Be sure to call[TypedArray.recycle()](https://developer.android.com/reference/kotlin/android/content/res/TypedArray#recycle())when you are done with the array.

|                                                                                                Parameters                                                                                                 ||
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `attrs` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html):The desired attributes. These attribute IDs must be sorted in ascending order. This value cannot be`null`. |

|                                                                                                                                                                  Return                                                                                                                                                                  ||
|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TypedArray](https://developer.android.com/reference/kotlin/android/content/res/TypedArray) | Returns a TypedArray holding an array of the attribute values. Be sure to call[TypedArray.recycle()](https://developer.android.com/reference/kotlin/android/content/res/TypedArray#recycle())when done with it. This value cannot be`null`. |

|                                                 Exceptions                                                  ||
|---------------------------------------------------|----------------------------------------------------------|
| `android.content.res.Resources.NotFoundException` | Throws NotFoundException if the given ID does not exist. |

**See Also**

- [Resources#obtainAttributes](https://developer.android.com/reference/kotlin/android/content/res/Resources#obtainAttributes(android.util.AttributeSet,%20kotlin.IntArray))
- [#obtainStyledAttributes(int, int[])](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(kotlin.Int,%20kotlin.IntArray))
- [#obtainStyledAttributes(AttributeSet, int[], int, int)](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#obtainStyledAttributes(android.util.AttributeSet,%20kotlin.IntArray,%20kotlin.Int,%20kotlin.Int))  

### rebase

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun rebase(): Unit
```

Rebases the theme against the parent Resource object's current configuration by re-applying the styles passed to[applyStyle(int,boolean)](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#applyStyle(kotlin.Int,%20kotlin.Boolean)).  

### resolveAttribute

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun resolveAttribute(
    resid: Int, 
    outValue: TypedValue!, 
    resolveRefs: Boolean
): Boolean
```

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

|                                                                                                                  Parameters                                                                                                                   ||
|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resid`       | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The resource identifier of the desired theme attribute.                                                                                             |
| `outValue`    | [TypedValue](https://developer.android.com/reference/kotlin/android/util/TypedValue.html#)!:Filled in with the ultimate resource value supplied by the attribute.                                                              |
| `resolveRefs` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):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. |

|                                                                                 Return                                                                                 ||
|------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | boolean Returns true if the attribute was found and outValue is valid, else false. |

### setTo

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setTo(other: Resources.Theme!): Unit
```

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](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme#)!:The existing Theme to copy from. |

### toString

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun toString(): String
```

|                                                          Return                                                          ||
|----------------------------------------------------------------------------------|----------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |