AnimatorSet

public final class AnimatorSet
extends Animator

java.lang.Object
   ↳ androidx.core.animation.Animator
     ↳ androidx.core.animation.AnimatorSet


This class plays a set of Animator objects in the specified order. Animations can be set up to play together, in sequence, or after a specified delay.

There are two different approaches to adding animations to a AnimatorSet: either the playTogether() or playSequentially() methods can be called to add a set of animations all at once, or the play(Animator) can be used in conjunction with methods in the Builder class to add animations one by one.

It is possible to set up a AnimatorSet with circular dependencies between its animations. For example, an animation a1 could be set up to start before animation a2, a2 before a3, and a3 before a1. The results of this configuration are undefined, but will typically result in none of the affected animations being played. Because of this (and because circular dependencies do not make logical sense anyway), circular dependencies should be avoided, and the dependency flow of animations should only be in one direction.

Developer Guides

For more information about animating with AnimatorSet, read the Property Animation developer guide.

Summary

Nested classes

class AnimatorSet.Builder

The Builder object is a utility class to facilitate adding animations to a AnimatorSet along with the relationships between the various animations. 

Inherited constants

Public constructors

AnimatorSet()

Public methods

boolean canReverse()

AnimatorSet is only reversible when the set contains no infinitely-repeating animation (e.g.

void cancel()

Cancels the animation.

Note that canceling a AnimatorSet also cancels all of the animations that it is responsible for.

AnimatorSet clone()
void end()

Ends the animation.

Note that ending a AnimatorSet also ends all of the animations that it is responsible for.

ArrayList<Animator> getChildAnimations()

Returns the current list of child Animator objects controlled by this AnimatorSet.

long getCurrentPlayTime()

Returns the milliseconds elapsed since the start of the animation.

long getDuration()

Gets the length of each of the child animations of this AnimatorSet.

Interpolator getInterpolator()

Returns the timing interpolator that this animation uses.

long getStartDelay()

The amount of time, in milliseconds, to delay starting the animation after start() is called.

long getTotalDuration()

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

boolean isRunning()

Returns true if any of the child animations of this AnimatorSet have been started and have not yet ended.

boolean isStarted()

Returns whether this Animator has been started and not yet ended.

void pause()

Pauses a running animation.

AnimatorSet.Builder play(Animator anim)

This method creates a Builder object, which is used to set up playing constraints.

void playSequentially(List<Animator> items)

Sets up this AnimatorSet to play each of the supplied animations when the previous animation ends.

void playSequentially(Animator... items)

Sets up this AnimatorSet to play each of the supplied animations when the previous animation ends.

void playTogether(Animator... items)

Sets up this AnimatorSet to play all of the supplied animations at the same time.

void playTogether(Collection<Animator> items)

Sets up this AnimatorSet to play all of the supplied animations at the same time.

void resume()

Resumes a paused animation, causing the animator to pick up where it left off when it was paused.

void reverse()

Plays the AnimatorSet in reverse.

void setCurrentPlayTime(long playTime)

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

AnimatorSet setDuration(long duration)

Sets the length of each of the current child animations of this AnimatorSet.

void setInterpolator(Interpolator interpolator)

Sets the Interpolator for all current child animations of this AnimatorSet.

void setStartDelay(long startDelay)

The amount of time, in milliseconds, to delay starting the animation after start() is called.

void setTarget(Object target)

Sets the target object for all current child animations of this AnimatorSet that take targets (ObjectAnimator and AnimatorSet).

void setupEndValues()

This method tells the object to use appropriate information to extract ending values for the animation.

void setupStartValues()