Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/animation/AnimatorSet.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/animation/AnimatorSet.Builder#inhmethods)

# AnimatorSet.Builder

*** ** * ** ***

` public class AnimatorSet.Builder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.animation.AnimatorSet.Builder |

<br />

*** ** * ** ***

The `Builder` object is a utility class to facilitate adding animations to a `AnimatorSet` along with the relationships between the various animations. The intention of the `Builder` methods, along with the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` method of `AnimatorSet` is to make it possible to express the dependency relationships of animations in a natural way. Developers can also use the `https://developer.android.com/reference/android/animation/AnimatorSet#playTogether(android.animation.Animator[])` and `https://developer.android.com/reference/android/animation/AnimatorSet#playSequentially(android.animation.Animator[])` methods if these suit the need, but it might be easier in some situations to express the AnimatorSet of animations in pairs.

<br />

The `Builder` object cannot be constructed directly, but is rather constructed internally via a call to `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)`.

<br />

For example, this sets up a AnimatorSet to play anim1 and anim2 at the same time, anim3 to play when anim2 finishes, and anim4 to play when anim3 finishes:

```
    AnimatorSet s = new AnimatorSet();
    s.play(anim1).with(anim2);
    s.play(anim2).before(anim3);
    s.play(anim4).after(anim3);
```

<br />

Note in the example that both `https://developer.android.com/reference/android/animation/AnimatorSet.Builder#before(android.animation.Animator)` and `https://developer.android.com/reference/android/animation/AnimatorSet.Builder#after(android.animation.Animator)` are used. These are just different ways of expressing the same relationship and are provided to make it easier to say things in a way that is more natural, depending on the situation.

<br />

It is possible to make several calls into the same `Builder` object to express multiple relationships. However, note that it is only the animation passed into the initial `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` method that is the dependency in any of the successive calls to the `Builder` object. For example, the following code starts both anim2 and anim3 when anim1 ends; there is no direct dependency relationship between anim2 and anim3:

```
  AnimatorSet s = new AnimatorSet();
  s.play(anim1).before(anim2).before(anim3);
```
If the desired result is to play anim1 then anim2 then anim3, this code expresses the relationship correctly:

<br />

```
  AnimatorSet s = new AnimatorSet();
  s.play(anim1).before(anim2);
  s.play(anim2).before(anim3);
```

<br />

Note that it is possible to express relationships that cannot be resolved and will not result in sensible results. For example, `play(anim1).after(anim1)` makes no sense. In general, circular dependencies like this one (or more indirect ones where a depends on b, which depends on c, which depends on a) should be avoided. Only create AnimatorSets that can boil down to a simple, one-way relationship of animations starting with, before, and after other, different, animations.

<br />

## Summary

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/animation/AnimatorSet.Builder` | ` https://developer.android.com/reference/android/animation/AnimatorSet.Builder#after(long)(long delay) ` Sets up the animation supplied in the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` call that created this `Builder` object to play when the given amount of time elapses. |
| ` https://developer.android.com/reference/android/animation/AnimatorSet.Builder` | ` https://developer.android.com/reference/android/animation/AnimatorSet.Builder#after(android.animation.Animator)(https://developer.android.com/reference/android/animation/Animator anim) ` Sets up the given animation to play when the animation supplied in the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` call that created this `Builder` object to start when the animation supplied in this method call ends. |
| ` https://developer.android.com/reference/android/animation/AnimatorSet.Builder` | ` https://developer.android.com/reference/android/animation/AnimatorSet.Builder#before(android.animation.Animator)(https://developer.android.com/reference/android/animation/Animator anim) ` Sets up the given animation to play when the animation supplied in the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` call that created this `Builder` object ends. |
| ` https://developer.android.com/reference/android/animation/AnimatorSet.Builder` | ` https://developer.android.com/reference/android/animation/AnimatorSet.Builder#with(android.animation.Animator)(https://developer.android.com/reference/android/animation/Animator anim) ` Sets up the given animation to play at the same time as the animation supplied in the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` call that created this `Builder` object. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public methods

### after

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AnimatorSet.Builder after (long delay)
```

Sets up the animation supplied in the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` call that created this `Builder` object to play when the given amount of time elapses.

<br />

| Parameters ||
|---|---|
| `delay` | `long`: The number of milliseconds that should elapse before the animation starts. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/animation/AnimatorSet.Builder` | <br /> |

### after

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AnimatorSet.Builder after (Animator anim)
```

Sets up the given animation to play when the animation supplied in the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` call that created this `Builder` object to start when the animation supplied in this method call ends.

<br />

| Parameters ||
|---|---|
| `anim` | `Animator`: The animation whose end will cause the animation supplied to the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` method to play. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/animation/AnimatorSet.Builder` | <br /> |

### before

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AnimatorSet.Builder before (Animator anim)
```

Sets up the given animation to play when the animation supplied in the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` call that created this `Builder` object ends.

<br />

| Parameters ||
|---|---|
| `anim` | `Animator`: The animation that will play when the animation supplied to the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` method ends. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/animation/AnimatorSet.Builder` | <br /> |

### with

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AnimatorSet.Builder with (Animator anim)
```

Sets up the given animation to play at the same time as the animation supplied in the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` call that created this `Builder` object.

<br />

| Parameters ||
|---|---|
| `anim` | `Animator`: The animation that will play when the animation supplied to the `https://developer.android.com/reference/android/animation/AnimatorSet#play(android.animation.Animator)` method starts. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/animation/AnimatorSet.Builder` | <br /> |