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 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 |
open Unit | |
open Int |
getAlpha() |
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 |
isPaused() 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() mutate() is not supported. |
open Unit |
pause() Pauses a running animation. |
open Unit |
registerAnimationCallback(@NonNull callback: SeekableAnimatedVectorDrawable.AnimationCallback) Adds a callback to listen to the animation events. |
open Unit |
resume() Resumes a paused animation. |
open Unit | |
open Unit |
setAutoMirrored(mirrored: Boolean) |
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 | |
open Unit |
setTintList(@Nullable tint: ColorStateList?) |
open Unit |
setTintMode(@Nullable tintMode: Mode?) |
open Boolean |
setVisible(visible: Boolean, restart: Boolean) |
open Unit |
start() |
open Unit |
stop() |
open Boolean |
unregisterAnimationCallback(@NonNull callback: SeekableAnimatedVectorDrawable.AnimationCallback) Removes the specified animation callback. |
Protected methods | |
---|---|
open Unit |
onBoundsChange(@NonNull bounds: Rect) |
open Boolean |
onLevelChange(level: Int) |
open Boolean |
onStateChange(@NonNull state: IntArray) |
Public methods
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.
getAlpha
@IntRange(0, 255) open fun getAlpha(): Int