Google is committed to advancing racial equity for Black communities. See how.

SeekableAnimatedVectorDrawable

open class SeekableAnimatedVectorDrawable : Drawable, Animatable
kotlin.Any
   ↳ 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 android.graphics.drawable.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 android.graphics.drawable.AnimatedVectorDrawable on any API levels.

Summary

Nested classes
abstract

Abstract class for animation callback.

Public methods
open Unit
applyTheme(@NonNull t: Theme)

open Boolean

open Unit

Removes all existing animation callbacks.

open static SeekableAnimatedVectorDrawable?
create(@NonNull context: Context, @DrawableRes resId: Int)

Create a SeekableAnimatedVectorDrawable object.

open static SeekableAnimatedVectorDrawable
createFromXmlInner(@NonNull r: Resources, @NonNull parser: XmlPullParser, @NonNull attrs: AttributeSet, @Nullable theme: Theme?)

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

open Unit
draw(@NonNull canvas: Canvas)

open Int

open Int

open ColorFilter?

open ConstantState?

open Long

Returns the milliseconds elapsed since the start of the animation.

open Int

open Int

open Int

open Long

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

open Unit
inflate(@NonNull res: Resources, @NonNull parser: XmlPullParser, @NonNull attrs: AttributeSet, @Nullable theme: Theme?)

open Unit
inflate(@NonNull res: Resources, @NonNull parser: XmlPullParser, @NonNull attrs: AttributeSet)

open Boolean

open Boolean

Returns whether the animation is currently in a paused state.

open Boolean

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

open Boolean

open Drawable

mutate() is not supported.

open Unit

Pauses a running animation.

open Unit

Adds a callback to listen to the animation events.

open Unit

Resumes a paused animation.

open Unit
setAlpha(@IntRange(0, 255) alpha: Int)

open Unit

open Unit
setColorFilter(@Nullable colorFilter: ColorFilter?)

open Unit
setCurrentPlayTime(@IntRange(0) playTime: Long)

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

open Unit
setTint(@ColorInt tint: Int)

open Unit
setTintList(@Nullable tint: ColorStateList?)

open Unit
setTintMode(@Nullable tintMode: Mode?)

open Boolean
setVisible(visible: Boolean, restart: Boolean)

open Unit

open Unit

open Boolean

Removes the specified animation callback.

Protected methods
open Unit
onBoundsChange(@NonNull bounds: Rect)

open Boolean

open Boolean
onStateChange(@NonNull state: IntArray)

Public methods

applyTheme

open fun applyTheme(@NonNull t: Theme): Unit

canApplyTheme

open fun canApplyTheme(): Boolean

clearAnimationCallbacks

open fun clearAnimationCallbacks(): Unit

Removes all existing animation callbacks.

create

@Nullable open static fun create(
    @NonNull context: Context,
    @DrawableRes resId: Int
): SeekableAnimatedVectorDrawable?

Create a SeekableAnimatedVectorDrawable object.

Parameters
context Context: the context for creating the animators.
resId Int: the resource ID for SeekableAnimatedVectorDrawable object.
Return
SeekableAnimatedVectorDrawable? a new SeekableAnimatedVectorDrawable or null if parsing error is found.

createFromXmlInner

@NonNull open static fun createFromXmlInner(
    @NonNull r: Resources,
    @NonNull parser: XmlPullParser,
    @NonNull attrs: AttributeSet,
    @Nullable theme: Theme?
): SeekableAnimatedVectorDrawable

Create a SeekableAnimatedVectorDrawable from inside an XML document using an optional Theme. Called on a parser positioned at a tag in an XML document, tries to create a Drawable from that tag. Returns null if the tag is not a valid drawable.

draw

open fun draw(@NonNull canvas: Canvas): Unit

getAlpha

@IntRange(0, 255) open fun getAlpha(): Int