AnimatedStateListDrawableCompat

public class AnimatedStateListDrawableCompat
extends Drawable implements Drawable.Callback

java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat


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

Summary

Public constructors

AnimatedStateListDrawableCompat()

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(ColorFilter colorFilter)
void setDither(boolean dither)
void setEnterFadeDuration(int ms)

Change the global fade duration when a new drawable is entering the scene.

void setExitFadeDuration(int ms)

Change the global fade duration when a new drawable is leaving the scene.

void setHotspot(float x, float y)
void setHotspotBounds(int left, int top, int right, int bottom)
void setTintList(ColorStateList tint)
void setTintMode(PorterDuff.Mode tintMode)
boolean setVisible(boolean visible, boolean restart)
void unscheduleDrawable(Drawable who, Runnable what)

Protected methods

void onBoundsChange(Rect bounds)
boolean onLevelChange(int level)
boolean onStateChange(int[] stateSet)

Inherited methods

Public constructors

AnimatedStateListDrawableCompat

public AnimatedStateListDrawableCompat ()

Public methods

addState

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

Add a new drawable to the set of keyframes.

Parameters
stateSet int: An array of resource IDs to associate with the keyframe

drawable Drawable: The drawable to show when in the specified state, may not be null

id int: The unique identifier for the keyframe