Android APIs
public static abstract class

Drawable.ConstantState

extends Object
java.lang.Object
   ↳ android.graphics.drawable.Drawable.ConstantState
Known Direct Subclasses

Class Overview

This abstract class is used by Drawables to store shared constant state and data between Drawables. BitmapDrawables created from the same resource will for instance share a unique bitmap stored in their ConstantState.

newDrawable(Resources) can be used as a factory to create new Drawable instances from this ConstantState.

Use getConstantState() to retrieve the ConstantState of a Drawable. Calling mutate() on a Drawable should typically create a new ConstantState for that Drawable.

Summary

Public Constructors
Drawable.ConstantState()
Public Methods
boolean canApplyTheme()
Return whether this constant state can have a theme applied.
abstract int getChangingConfigurations()
Return a bit mask of configuration changes that will impact this drawable (and thus require completely reloading it).
abstract Drawable newDrawable()
Create a new drawable without supplying resources the caller is running in.
Drawable newDrawable(Resources res)
Create a new Drawable instance from its constant state.
Drawable newDrawable(Resources res, Resources.Theme theme)
Create a new Drawable instance from its constant state.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Drawable.ConstantState ()

Added in API level 1

Public Methods

public boolean canApplyTheme ()

Return whether this constant state can have a theme applied.

public abstract int getChangingConfigurations ()

Added in API level 1

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

public abstract Drawable newDrawable ()

Added in API level 1

Create a new drawable without supplying resources the caller is running in. Note that using this means the density-dependent drawables (like bitmaps) will not be able to update their target density correctly. One should use newDrawable(Resources) instead to provide a resource.

public Drawable newDrawable (Resources res)

Added in API level 5

Create a new Drawable instance from its constant state. This must be implemented for drawables that change based on the target density of their caller (that is depending on whether it is in compatibility mode).

public Drawable newDrawable (Resources res, Resources.Theme theme)

Create a new Drawable instance from its constant state. This must be implemented for drawables that can have a theme applied.