Android Guides | Samples

Android.Graphics.Drawables.AnimatedVectorDrawable Class

This class uses ObjectAnimator and AnimatorSet to animate the properties of a VectorDrawable to create an animated drawable.

See Also: AnimatedVectorDrawable

Syntax

[Android.Runtime.Register("android/graphics/drawable/AnimatedVectorDrawable", DoNotGenerateAcw=true)]
public class AnimatedVectorDrawable : Drawable, IAnimatable, IDisposable

Remarks

This class uses ObjectAnimator and AnimatorSet to animate the properties of a VectorDrawable to create an animated drawable. Here is a simple VectorDrawable in this vectordrawable.xml file. Here is a simple AnimatedVectorDrawable defined in this avd.xml file. Note how we use the names to refer to the groups and paths in the vectordrawable.xml. Here is the rotation.xml, which will rotate the target group for 360 degrees. Here is the path_morph.xml, which will morph the path from one shape to the other. Note that the paths must be compatible for morphing. In more details, the paths should have exact same length of commands , and exact same length of parameters for each commands. Note that the path strings are better stored in strings.xml for reusing.

AnimatedVectorDrawable are normally defined as 3 separate XML files.

First is the XML file for VectorDrawable. Note that we allow the animation to happen on the group's attributes and path's attributes, which requires they are uniquely named in this XML file. Groups and paths without animations do not need names.

Second is the AnimatedVectorDrawable's XML file, which defines the target VectorDrawable, the target paths and groups to animate, the properties of the path and group to animate and the animations defined as the ObjectAnimators or AnimatorSets.

Last is the Animator XML file, which is the same as a normal ObjectAnimator or AnimatorSet. To complete this example, here are the 2 animator files used in avd.xml: rotation.xml and path_morph.xml.

[Android Documentation]

Requirements

Namespace: Android.Graphics.Drawables
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0

The members of Android.Graphics.Drawables.AnimatedVectorDrawable are listed below.

See Also: Drawable

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

[read-only]
IsRunningBoolean. Indicates whether the animation is running.
[read-only]
override
OpacityInt32. Return the opacity/transparency of this Drawable.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

override
Draw(Canvas)
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).
override
SetAlpha(Int32)
Specify an alpha value for the drawable. 0 means fully transparent, and 255 means fully opaque.
override
SetColorFilter(ColorFilter)
Specify an optional color filter for the drawable.
Start()
Starts the drawable's animation.
Stop()
Stops the drawable's animation.