Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Drawable.ConstantState

public static abstract class Drawable.ConstantState
extends Object

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


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.

Inherited methods

From class java.lang.Object

Public constructors

Drawable.ConstantState

Added in API level 1
Drawable.ConstantState ()

Public methods

canApplyTheme

Added in API level 21
boolean canApplyTheme ()

Return whether this constant state can have a theme applied.

Returns
boolean

getChangingConfigurations

Added in API level 1
int getChangingConfigurations ()

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

Returns
int

newDrawable

Added in API level 1
Drawable newDrawable ()

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.

Returns
Drawable

newDrawable

Added in API level 5
Drawable newDrawable (Resources res)

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).

Parameters
res Resources
Returns
Drawable

newDrawable

Added in API level 21
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.

Parameters
res Resources
theme Resources.Theme
Returns
Drawable
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.