public class AnimatedStateListDrawableCompat
extends Drawable implements Drawable.Callback


A Drawable providing animated transitions between states.

A port of AnimatedStateListDrawable compatible with older versions of the platform.

This drawable can be defined in an XML file with the <animated-selector> element. Each keyframe Drawable is defined in a nested <item> element. Transitions are defined in a nested <transition> element.

Notable exceptions not supported by this class:

  • drawables defined as children of <item>s or <transition>s (except vectors) ignore theme attributes prior to API level 21
  • Animated vector transitions do not support reversing prior to API level 24
R.attr.state_focused R.attr.state_window_focused R.attr.state_enabled R.attr.state_checkable R.attr.state_checked R.attr.state_selected R.attr.state_activated R.attr.state_active R.attr.state_single R.attr.state_first R.attr.state_middle R.attr.state_last R.attr.state_pressed


Public constructors


Public methods

void addState(int[] stateSet, Drawable drawable, int id)

Add a new drawable to the set of keyframes.

void addState(int[] stateSet, Drawable drawable)

Add a new image/string ID to the set of images.

<T extends Drawable & Animatable> void addTransition(int fromId, int toId, T transition, boolean reversible)

Adds a new transition between keyframes.

void applyTheme(Resources.Theme theme)
boolean canApplyTheme()
static AnimatedStateListDrawableCompat create(Context context, int resId, Resources.Theme theme)

Creates an AnimatedStateListDrawableCompat.

static AnimatedStateListDrawableCompat createFromXmlInner(Context context, Resources resources, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme)

Create a AnimatedStateListDrawableCompat from inside an XML document using an optional Resources.Theme.

void draw(Canvas canvas)
int getAlpha()
int getChangingConfigurations()
final Drawable.ConstantState getConstantState()
Drawable getCurrent()
void getHotspotBounds(Rect outRect)
int getIntrinsicHeight()
int getIntrinsicWidth()
int getMinimumHeight()
int getMinimumWidth()
int getOpacity()
void getOutline(Outline outline)
boolean getPadding(Rect padding)
void inflate(Context context, Resources resources, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme)

Inflate this Drawable from an XML resource optionally styled by a theme.

void invalidateDrawable(Drawable who)
boolean isAutoMirrored()
boolean isStateful()
void jumpToCurrentState()
Drawable mutate()
boolean onLayoutDirectionChanged(int layoutDirection)
void scheduleDrawable(Drawable who, Runnable what, long when)
void setAlpha(int alpha)
void setAutoMirrored(boolean mirrored)
void setColorFilter(ColorFi