# Animator

Artifact: [androidx.core:core-animation](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/animation/Animator.java+class:androidx.core.animation.Animator) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

*** ** * ** ***


```
public abstract class Animator implements Cloneable
```

<br />

Known direct subclasses [AnimatorSet](https://developer.android.com/reference/androidx/core/animation/AnimatorSet), [ValueAnimator](https://developer.android.com/reference/androidx/core/animation/ValueAnimator)

|---|---|
| `https://developer.android.com/reference/androidx/core/animation/AnimatorSet` | This class plays a set of `https://developer.android.com/reference/androidx/core/animation/Animator` objects in the specified order. |
| `https://developer.android.com/reference/androidx/core/animation/ValueAnimator` | This class provides a simple timing engine for running animations which calculate animated values and set them on target objects. |

Known indirect subclasses [ObjectAnimator](https://developer.android.com/reference/androidx/core/animation/ObjectAnimator), [TimeAnimator](https://developer.android.com/reference/androidx/core/animation/TimeAnimator)

|---|---|
| `https://developer.android.com/reference/androidx/core/animation/ObjectAnimator` | This subclass of `https://developer.android.com/reference/androidx/core/animation/ValueAnimator` provides support for animating properties on target objects. |
| `https://developer.android.com/reference/androidx/core/animation/TimeAnimator` | This class provides a simple callback mechanism to listeners that is synchronized with all other animators in the system. |

*** ** * ** ***

This is the superclass for classes which provide basic support for animations which can be started, ended, and have `AnimatorListeners` added to them.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorListener` An animation listener receives notifications from an animation. |
| `public interface https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorPauseListener` A pause listener receives notifications from an animation when the animation is `https://developer.android.com/reference/androidx/core/animation/Animator#pause()` or `https://developer.android.com/reference/androidx/core/animation/Animator#resume()`. |
| `public interface https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorUpdateListener` Implementors of this interface can add themselves as update listeners to an `ValueAnimator` instance to receive callbacks on every animation frame, after the current frame's values have been calculated for that `ValueAnimator`. |

| ### Constants |
|---|---|
| `static final long` | `https://developer.android.com/reference/androidx/core/animation/Animator#DURATION_INFINITE() = -1` The value used to indicate infinite duration (e.g. when Animators repeat infinitely). |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/animation/Animator#Animator()()` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#addListener(androidx.core.animation.Animator.AnimatorListener)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorListener listener)` Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#addPauseListener(androidx.core.animation.Animator.AnimatorPauseListener)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorPauseListener listener)` Adds a pause listener to this animator. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#addUpdateListener(androidx.core.animation.Animator.AnimatorUpdateListener)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorUpdateListener listener)` Adds a listener to the set of listeners that are sent update events through the life of an animation. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#cancel()()` Cancels the animation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator` | `https://developer.android.com/reference/androidx/core/animation/Animator#clone()()` |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#end()()` Ends the animation. |
| `abstract long` | `https://developer.android.com/reference/androidx/core/animation/Animator#getDuration()()` Gets the duration of the animation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/animation/Interpolator` | `https://developer.android.com/reference/androidx/core/animation/Animator#getInterpolator()()` Returns the timing interpolator that this animation uses. |
| `abstract long` | `https://developer.android.com/reference/androidx/core/animation/Animator#getStartDelay()()` The amount of time, in milliseconds, to delay processing the animation after `https://developer.android.com/reference/androidx/core/animation/Animator#start()` is called. |
| `long` | `https://developer.android.com/reference/androidx/core/animation/Animator#getTotalDuration()()` Gets the total duration of the animation, accounting for animation sequences, start delay, and repeating. |
| `boolean` | `https://developer.android.com/reference/androidx/core/animation/Animator#isPaused()()` Returns whether this animator is currently in a paused state. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/core/animation/Animator#isRunning()()` Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended). |
| `boolean` | `https://developer.android.com/reference/androidx/core/animation/Animator#isStarted()()` Returns whether this Animator has been started and not yet ended. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#pause()()` Pauses a running animation. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#removeAllListeners()()` Removes all `https://developer.android.com/reference/androidx/core/animation/Animator#addListener(androidx.core.animation.Animator.AnimatorListener)` and `https://developer.android.com/reference/androidx/core/animation/Animator#addPauseListener(androidx.core.animation.Animator.AnimatorPauseListener)` from this object. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#removeAllUpdateListeners()()` Removes all listeners from the set listening to frame updates for this animation. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#removeListener(androidx.core.animation.Animator.AnimatorListener)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorListener listener)` Removes a listener from the set listening to this animation. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#removePauseListener(androidx.core.animation.Animator.AnimatorPauseListener)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorPauseListener listener)` Removes a pause listener from the set listening to this animation. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#removeUpdateListener(androidx.core.animation.Animator.AnimatorUpdateListener)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorUpdateListener listener)` Removes a listener from the set listening to frame updates for this animation. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#resume()()` Resumes a paused animation, causing the animator to pick up where it left off when it was paused. |
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator` | `https://developer.android.com/reference/androidx/core/animation/Animator#setDuration(long)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long duration)` Sets the duration of the animation. |
| `abstract void` | `https://developer.android.com/reference/androidx/core/animation/Animator#setInterpolator(androidx.core.animation.Interpolator)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/animation/Interpolator value)` The interpolator used in calculating the elapsed fraction of the animation. |
| `abstract void` | `https://developer.android.com/reference/androidx/core/animation/Animator#setStartDelay(long)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long startDelay)` The amount of time, in milliseconds, to delay processing the animation after `https://developer.android.com/reference/androidx/core/animation/Animator#start()` is called. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#setTarget(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html target)` Sets the target object whose property will be animated by this animation. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#setupEndValues()()` This method tells the object to use appropriate information to extract ending values for the animation. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#setupStartValues()()` This method tells the object to use appropriate information to extract starting values for the animation. |
| `void` | `https://developer.android.com/reference/androidx/core/animation/Animator#start()()` Starts this animation. |

## Constants

### DURATION_INFINITE

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public static final long DURATION_INFINITE = -1
```

The value used to indicate infinite duration (e.g. when Animators repeat infinitely).

## Public constructors

### Animator

Added in 1.0.0

```
public Animator()
```

## Public methods

### addListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void addListener(@NonNull Animator.AnimatorListener listener)
```

Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorListener listener` | the listener to be added to the current set of listeners for this animation. |

### addPauseListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void addPauseListener(@NonNull Animator.AnimatorPauseListener listener)
```

Adds a pause listener to this animator.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorPauseListener listener` | the listener to be added to the current set of pause listeners for this animation. |

### addUpdateListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void addUpdateListener(@NonNull Animator.AnimatorUpdateListener listener)
```

Adds a listener to the set of listeners that are sent update events through the life of an animation. This method is called on all listeners for every frame of the animation, after the values for the animation have been calculated.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorUpdateListener listener` | the listener to be added to the current set of listeners for this animation. |

### cancel

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void cancel()
```

Cancels the animation. Unlike `https://developer.android.com/reference/androidx/core/animation/Animator#end()`, `cancel()` causes the animation to stop in its tracks, sending an `https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorListener#onAnimationCancel(androidx.core.animation.Animator)` to its listeners, followed by an `https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorListener#onAnimationEnd(androidx.core.animation.Animator)` message.

This method must be called on the thread that is running the animation.

### clone

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public @NonNull Animator clone()
```

### end

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void end()
```

Ends the animation. This causes the animation to assign the end value of the property being animated, then calling the `https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorListener#onAnimationEnd(androidx.core.animation.Animator)` method on its listeners.

This method must be called on the thread that is running the animation.

### getDuration

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public abstract long getDuration()
```

Gets the duration of the animation.

| Returns |
|---|---|
| `long` | The length of the animation, in milliseconds. |

### getInterpolator

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public @Nullable Interpolator getInterpolator()
```

Returns the timing interpolator that this animation uses.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/animation/Interpolator` | The timing interpolator for this animation. |

### getStartDelay

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public abstract long getStartDelay()
```

The amount of time, in milliseconds, to delay processing the animation after `https://developer.android.com/reference/androidx/core/animation/Animator#start()` is called.

| Returns |
|---|---|
| `long` | the number of milliseconds to delay running the animation |

### getTotalDuration

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public long getTotalDuration()
```

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

When the animation repeats infinite times, or when any of the child animators does (via `https://developer.android.com/reference/androidx/core/animation/ValueAnimator#setRepeatCount(int)`} to `https://developer.android.com/reference/androidx/core/animation/ValueAnimator#INFINITE()`), the total duration will be `https://developer.android.com/reference/androidx/core/animation/Animator#DURATION_INFINITE()`. Otherwise, the total duration is the sum of start delay and animation running time (i.e. duration of one iteration multiplied by the number of iterations).

| Returns |
|---|---|
| `long` | Total time an animation takes to finish, starting from the time `https://developer.android.com/reference/androidx/core/animation/Animator#start()` is called. `https://developer.android.com/reference/androidx/core/animation/Animator#DURATION_INFINITE()` will be returned if the animation or any child animation repeats infinite times. |

### isPaused

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public boolean isPaused()
```

Returns whether this animator is currently in a paused state.

| Returns |
|---|---|
| `boolean` | True if the animator is currently paused, false otherwise. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/animation/Animator#pause()` |   |
| `https://developer.android.com/reference/androidx/core/animation/Animator#resume()` |   |

### isRunning

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public abstract boolean isRunning()
```

Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended).

| Returns |
|---|---|
| `boolean` | Whether the Animator is running. |

### isStarted

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public boolean isStarted()
```

Returns whether this Animator has been started and not yet ended. For reusable Animators (which most Animators are, apart from the one-shot animator produced by `https://developer.android.com/reference/android/view/ViewAnimationUtils.html#createCircularReveal(android.view.View, int, int, float, float)`), this state is a superset of `https://developer.android.com/reference/androidx/core/animation/Animator#isRunning()`, because an Animator with a nonzero `https://developer.android.com/reference/androidx/core/animation/Animator#getStartDelay()` will return true for `https://developer.android.com/reference/androidx/core/animation/Animator#isStarted()` during the delay phase, whereas `https://developer.android.com/reference/androidx/core/animation/Animator#isRunning()` will return true only after the delay phase is complete. Non-reusable animators will always return true after they have been started, because they cannot return to a non-started state.

| Returns |
|---|---|
| `boolean` | Whether the Animator has been started and not yet ended. |

### pause

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void pause()
```

Pauses a running animation. This method should only be called on the same thread on which the animation was started. If the animation has not yet been `https://developer.android.com/reference/androidx/core/animation/Animator#isStarted()` or has since ended, then the call is ignored. Paused animations can be resumed by calling `https://developer.android.com/reference/androidx/core/animation/Animator#resume()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/animation/Animator#resume()` |   |
| `https://developer.android.com/reference/androidx/core/animation/Animator#isPaused()` |   |
| `https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorPauseListener` |   |

### removeAllListeners

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void removeAllListeners()
```

Removes all `https://developer.android.com/reference/androidx/core/animation/Animator#addListener(androidx.core.animation.Animator.AnimatorListener)` and `https://developer.android.com/reference/androidx/core/animation/Animator#addPauseListener(androidx.core.animation.Animator.AnimatorPauseListener)` from this object.

### removeAllUpdateListeners

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void removeAllUpdateListeners()
```

Removes all listeners from the set listening to frame updates for this animation.

### removeListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void removeListener(@NonNull Animator.AnimatorListener listener)
```

Removes a listener from the set listening to this animation.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorListener listener` | the listener to be removed from the current set of listeners for this animation. |

### removePauseListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void removePauseListener(@NonNull Animator.AnimatorPauseListener listener)
```

Removes a pause listener from the set listening to this animation.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorPauseListener listener` | the listener to be removed from the current set of pause listeners for this animation. |

### removeUpdateListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void removeUpdateListener(@NonNull Animator.AnimatorUpdateListener listener)
```

Removes a listener from the set listening to frame updates for this animation.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorUpdateListener listener` | the listener to be removed from the current set of update listeners for this animation. |

### resume

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void resume()
```

Resumes a paused animation, causing the animator to pick up where it left off when it was paused. This method should only be called on the same thread on which the animation was started. Calls to resume() on an animator that is not currently paused will be ignored.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/animation/Animator#pause()` |   |
| `https://developer.android.com/reference/androidx/core/animation/Animator#isPaused()` |   |
| `https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorPauseListener` |   |

### setDuration

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public abstract @NonNull Animator setDuration(@IntRange(from = 0) long duration)
```

Sets the duration of the animation.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long duration` | The length of the animation, in milliseconds. |

### setInterpolator

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public abstract void setInterpolator(@Nullable Interpolator value)
```

The interpolator used in calculating the elapsed fraction of the animation. The interpolator determines whether the animation runs with linear or non-linear motion, such as acceleration and deceleration. The default value is `https://developer.android.com/reference/androidx/core/animation/AccelerateDecelerateInterpolator`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/animation/Interpolator value` | the interpolator to be used by this animation, or `null` to use the default one. |

### setStartDelay

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public abstract void setStartDelay(@IntRange(from = 0) long startDelay)
```

The amount of time, in milliseconds, to delay processing the animation after `https://developer.android.com/reference/androidx/core/animation/Animator#start()` is called.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long startDelay` | The amount of the delay, in milliseconds |

### setTarget

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void setTarget(@Nullable Object target)
```

Sets the target object whose property will be animated by this animation. Not all subclasses operate on target objects (for example, `https://developer.android.com/reference/androidx/core/animation/ValueAnimator`, but this method is on the superclass for the convenience of dealing generically with those subclasses that do handle targets.

**Note:** The target is stored as a weak reference internally to avoid leaking resources by having animators directly reference old targets. Therefore, you should ensure that animator targets always have a hard reference elsewhere.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html target` | The object being animated |

### setupEndValues

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void setupEndValues()
```

This method tells the object to use appropriate information to extract ending values for the animation. For example, a AnimatorSet object will pass this call to its child objects to tell them to set up the values. A ObjectAnimator object will use the information it has about its target object and PropertyValuesHolder objects to get the start values for its properties. A ValueAnimator object will ignore the request since it does not have enough information (such as a target object) to gather these values.

### setupStartValues

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void setupStartValues()
```

This method tells the object to use appropriate information to extract starting values for the animation. For example, a AnimatorSet object will pass this call to its child objects to tell them to set up the values. A ObjectAnimator object will use the information it has about its target object and PropertyValuesHolder objects to get the start values for its properties. A ValueAnimator object will ignore the request since it does not have enough information (such as a target object) to gather these values.

### start

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public void start()
```

Starts this animation. If the animation has a nonzero startDelay, the animation will start running after that delay elapses. A non-delayed animation will have its initial value(s) set immediately, followed by calls to `https://developer.android.com/reference/androidx/core/animation/Animator.AnimatorListener#onAnimationStart(androidx.core.animation.Animator)` for any listeners of this animator.

The animation started by calling this method will be run on the thread that called this method. This thread should have a Looper on it (a runtime exception will be thrown if this is not the case). Also, if the animation will animate properties of objects in the view hierarchy, then the calling thread should be the UI thread for that view hierarchy.