SeekableAnimatedVectorDrawable

public class SeekableAnimatedVectorDrawable
extends Drawable implements Animatable

java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ androidx.vectordrawable.graphics.drawable.SeekableAnimatedVectorDrawable


This class animates properties of a VectorDrawableCompat with animations defined using ObjectAnimator or AnimatorSet.

SeekableAnimatedVectorDrawable is defined in the same XML format as AnimatedVectorDrawable.

Here are all the animatable attributes in VectorDrawableCompat:

Element Name Animatable attribute name
<vector> alpha
<group> rotation
pivotX
pivotY
scaleX
scaleY
translateX
translateY
<path> fillColor
pathData
strokeColor
strokeWidth
strokeAlpha
fillAlpha
trimPathStart
trimPathEnd
trimPathOffset

You can always create a SeekableAnimatedVectorDrawable object and use it as a Drawable by the Java API. In order to refer to SeekableAnimatedVectorDrawable inside an XML file, you can use app:srcCompat attribute in AppCompat library's ImageButton or ImageView.

SeekableAnimatedVectorDrawable supports the following features too:

  • Path Morphing (PathType evaluator). This is used for morphing one path into another.
  • Path Interpolation. This is used to defined a flexible interpolator (represented as a path) instead of the system defined ones like LinearInterpolator.
  • Animating 2 values in one ObjectAnimator according to one path's X value and Y value. One usage is moving one object in both X and Y dimensions along an path.

Unlike AnimatedVectorDrawableCompat, this class does not delegate to the platform AnimatedVectorDrawable on any API levels.

Summary

Nested classes

class SeekableAnimatedVectorDrawable.AnimationCallback

Abstract class for animation callback. 

Public methods

void applyTheme(Resources.Theme t)
boolean canApplyTheme()
void clearAnimationCallbacks()

Removes all existing animation callbacks.

static SeekableAnimatedVectorDrawable create(Context context, int resId)

Create a SeekableAnimatedVectorDrawable object.

static SeekableAnimatedVectorDrawable createFromXmlInner(Resources r, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme)

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

void draw(Canvas canvas)
int getAlpha()
int getChangingConfigurations()
ColorFilter getColorFilter()
Drawable.ConstantState getConstantState()
long getCurrentPlayTime()

Returns the milliseconds elapsed since the start of the animation.

int getIntrinsicHeight()
int getIntrinsicWidth()
int getOpacity()

This method is deprecated. This method is no longer used in graphics optimizations

long getTotalDuration()

Gets the total duration of the animation, accounting for animation sequences, start delay, and repeating.

void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme)
void inflate(Resources res, XmlPullParser parser, AttributeSet attrs)
boolean isAutoMirrored()
boolean isPaused()

Returns whether the animation is currently in a paused state.

boolean isRunning()

Returns whether the animation is running (has started and not yet ended).

boolean isStateful()
Drawable mutate()

mutate() is not supported.

void pause()

Pauses a running animation.

void registerAnimationCallback(SeekableAnimatedVectorDrawable.AnimationCallback callback)

Adds a callback to listen to the animation events.

void resume()

Resumes a paused animation.

void setAlpha(int alpha)
void setAutoMirrored(boolean mirrored)
void setColorFilter(ColorFilter colorFilter)
void setCurrentPlayTime(long playTime)

Sets the position of the animation to the specified point in time.

void setTint(int tint)
void setTintList(ColorStateList tint)
void setTintMode(PorterDuff.Mode tintMode)
boolean setVisible(boolean visible, boolean restart)
void start()
void stop()
boolean unregisterAnimationCallback(SeekableAnimatedVectorDrawable.AnimationCallback callback)

Removes the specified animation callback.

Protected methods

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

Inherited methods

Public methods

applyTheme

public void applyTheme (Resources.Theme t)

Parameters
t Resources.Theme

canApplyTheme

public boolean canApplyTheme ()

Returns
boolean