public abstract static class Drawable.ConstantState extends Object
Drawable
s to store shared constant state and data
between Drawables. BitmapDrawable
s 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.
Drawable.getConstantState()
to retrieve the ConstantState of a Drawable. Calling
Drawable.mutate()
on a Drawable should typically create a new ConstantState for that
Drawable.Constructor and Description |
---|
ConstantState() |
Modifier and Type | Method and Description |
---|---|
int |
addAtlasableBitmaps(Collection<Bitmap> atlasList) |
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).
|
protected boolean |
isAtlasable(Bitmap bitmap) |
abstract Drawable |
newDrawable()
Creates a new Drawable instance from its constant state.
|
Drawable |
newDrawable(Resources res)
Creates a new Drawable instance from its constant state using the
specified resources.
|
Drawable |
newDrawable(Resources res,
Resources.Theme theme)
Creates a new Drawable instance from its constant state using the
specified resources and theme.
|
public abstract Drawable newDrawable()
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(Resources)
instead to
provide an appropriate Resources object.
#newDrawable(Resources)}
public Drawable newDrawable(Resources res)
The default implementation for this method calls through to
newDrawable()
.
res
- the resources of the context in which the drawable will
be displayedpublic Drawable newDrawable(Resources res, Resources.Theme theme)
The default implementation for this method calls through to
newDrawable(Resources)
.
res
- the resources of the context in which the drawable will
be displayedtheme
- the theme of the context in which the drawable will be
displayedpublic abstract int getChangingConfigurations()
public int addAtlasableBitmaps(Collection<Bitmap> atlasList)
protected final boolean isAtlasable(Bitmap bitmap)
public boolean canApplyTheme()