to top
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
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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Drawable.ConstantState ()

Since: API Level 1

Public Methods

public abstract int getChangingConfigurations ()

Since: 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 ()

Since: 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)

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