# Drawable.ConstantState

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

# ConstantState

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/graphics/drawable/Drawable.ConstantState "View this page in Java")  

```
abstract class ConstantState
```

|---|------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                       ||
| ↳ | [android.graphics.drawable.Drawable.ConstantState](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#) |

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [DrawableContainer.DrawableContainerState](https://developer.android.com/reference/kotlin/android/graphics/drawable/DrawableContainer.DrawableContainerState) |---------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------| | [DrawableContainer.DrawableContainerState](https://developer.android.com/reference/kotlin/android/graphics/drawable/DrawableContainer.DrawableContainerState) | A ConstantState that can contain several[Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable)s. | |

This abstract class is used by[Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable)s to store shared constant state and data between Drawables.[BitmapDrawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/BitmapDrawable)s created from the same resource will for instance share a unique bitmap stored in their ConstantState.

[newDrawable(android.content.res.Resources)](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#newDrawable(android.content.res.Resources))can be used as a factory to create new Drawable instances from this ConstantState.
Use[Drawable.getConstantState()](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable#getConstantState())to retrieve the ConstantState of a Drawable. Calling[Drawable.mutate()](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable#mutate())on a Drawable should typically create a new ConstantState for that Drawable.

## Summary

|                                                              Public constructors                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------------|---|
| [ConstantState](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#ConstantState())`()` <br /> |

|                                                                                                                                                                                                                                                                                                                 Public methods                                                                                                                                                                                                                                                                                                                 ||
|-------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                | [canApplyTheme](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#canApplyTheme())`()` Return whether this constant state can have a theme applied.                                                                                                                                                                                                                                                                                                                                       |
| abstract[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                    | [getChangingConfigurations](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#getChangingConfigurations())`()` Return a bit mask of configuration changes that will impact this drawable (and thus require completely reloading it).                                                                                                                                                                                                                                                      |
| abstract[Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable) | [newDrawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#newDrawable())`()` Creates a new Drawable instance from its constant state.                                                                                                                                                                                                                                                                                                                                               |
| open[Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable)     | [newDrawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#newDrawable(android.content.res.Resources))`(`res:` `[Resources](https://developer.android.com/reference/kotlin/android/content/res/Resources.html#)?`)` Creates a new Drawable instance from its constant state using the specified resources.                                                                                                                                                                           |
| open[Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable)     | [newDrawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#newDrawable(android.content.res.Resources,%20android.content.res.Resources.Theme))`(`res:` `[Resources](https://developer.android.com/reference/kotlin/android/content/res/Resources.html#)?`, `theme:` `[Resources.Theme](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme.html#)?`)` Creates a new Drawable instance from its constant state using the specified resources and theme. |

## Public constructors

### ConstantState

```
ConstantState()
```

## Public methods

### canApplyTheme

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

```
open fun canApplyTheme(): Boolean
```

Return whether this constant state can have a theme applied.  

### getChangingConfigurations

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

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

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

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

### newDrawable

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

```
abstract fun newDrawable(): Drawable
```

Creates a new Drawable instance from its constant state.

**Note:** Using this method means density-dependent properties, such as pixel dimensions or bitmap images, will not be updated to match the density of the target display. To ensure correct scaling, use[newDrawable(android.content.res.Resources)](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#newDrawable(android.content.res.Resources))instead to provide an appropriate Resources object.

|                                                                                    Return                                                                                     ||
|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| [Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable) | a new drawable object based on this constant state This value cannot be`null`. |

**See Also**

- [#newDrawable(Resources)](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#newDrawable(android.content.res.Resources))  

### newDrawable

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

```
open fun newDrawable(res: Resources?): Drawable
```

Creates a new Drawable instance from its constant state using the specified resources. This method should be implemented for drawables that have density-dependent properties.

The default implementation for this method calls through to[newDrawable()](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#newDrawable()).

|                                                                                              Parameters                                                                                               ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `res` | [Resources](https://developer.android.com/reference/kotlin/android/content/res/Resources.html#)?:the resources of the context in which the drawable will be displayed This value may be`null`. |

|                                                                                    Return                                                                                     ||
|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| [Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable) | a new drawable object based on this constant state This value cannot be`null`. |

### newDrawable

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

```
open fun newDrawable(
    res: Resources?, 
    theme: Resources.Theme?
): Drawable
```

Creates a new Drawable instance from its constant state using the specified resources and theme. This method should be implemented for drawables that have theme-dependent properties.

The default implementation for this method calls through to[newDrawable(android.content.res.Resources)](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.ConstantState#newDrawable(android.content.res.Resources)).

|                                                                                                   Parameters                                                                                                    ||
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `res`   | [Resources](https://developer.android.com/reference/kotlin/android/content/res/Resources.html#)?:the resources of the context in which the drawable will be displayed This value may be`null`.         |
| `theme` | [Resources.Theme](https://developer.android.com/reference/kotlin/android/content/res/Resources.Theme.html#)?:the theme of the context in which the drawable will be displayed This value may be`null`. |

|                                                                                    Return                                                                                     ||
|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| [Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable) | a new drawable object based on this constant state This value cannot be`null`. |