Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#constants) \| [Ctors](https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#pubctors) \| [Methods](https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#inhmethods)

# WindowInsetsAnimation.Callback

*** ** * ** ***


`
public
static

abstract
class
WindowInsetsAnimation.Callback
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.WindowInsetsAnimation.Callback |

<br />

*** ** * ** ***

Interface that allows the application to listen to animation events for windows that cause
insets.


Note: Applications that want to observe the lifecycle of window insets animations but do
not need to synchronize view layouts or draw frames with the animation on every frame should
prefer `https://developer.android.com/reference/android/view/ViewTreeObserver.WindowInsetsAnimationListener` to allow the
system to optimize the animation e.g. by moving it to a different thread.
**See also:**

- `https://developer.android.com/reference/android/view/ViewTreeObserver.WindowInsetsAnimationListener`

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_CONTINUE_ON_SUBTREE` Return value for `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()`: Dispatching of animation events should continue in the view hierarchy. |
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_STOP` Return value for `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()`: Dispatching of animation events should stop at this level in the view hierarchy, and no animation events should be dispatch to the subtree of the view hierarchy. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#Callback(int)(int dispatchMode) ` Creates a new `https://developer.android.com/reference/android/view/WindowInsetsAnimation` callback with the given `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()`. |

| ### Public methods ||
|---|---|
| ` final int` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()() ` Retrieves the dispatch mode of this listener. |
| ` void` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onEnd(android.view.WindowInsetsAnimation)(https://developer.android.com/reference/android/view/WindowInsetsAnimation animation) ` Called when an insets animation has ended. |
| ` void` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onPrepare(android.view.WindowInsetsAnimation)(https://developer.android.com/reference/android/view/WindowInsetsAnimation animation) ` Called when an insets animation is about to start and before the views have been laid out in the end state of the animation. |
| ` abstract https://developer.android.com/reference/android/view/WindowInsets` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onProgress(android.view.WindowInsets,%20java.util.List<android.view.WindowInsetsAnimation>)(https://developer.android.com/reference/android/view/WindowInsets insets, https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/view/WindowInsetsAnimation> runningAnimations) ` Called when the insets change as part of running an animation. |
| ` https://developer.android.com/reference/android/view/WindowInsetsAnimation.Bounds` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onStart(android.view.WindowInsetsAnimation,%20android.view.WindowInsetsAnimation.Bounds)(https://developer.android.com/reference/android/view/WindowInsetsAnimation animation, https://developer.android.com/reference/android/view/WindowInsetsAnimation.Bounds bounds) ` Called when an insets animation gets started. |

### 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*.


## Constants

### DISPATCH_MODE_CONTINUE_ON_SUBTREE

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

```
public static final int DISPATCH_MODE_CONTINUE_ON_SUBTREE
```

Return value for `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()`: Dispatching of animation events should
continue in the view hierarchy.

<br />

Constant Value:

1
(0x00000001)


### DISPATCH_MODE_STOP

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

```
public static final int DISPATCH_MODE_STOP
```

Return value for `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()`: Dispatching of animation events should
stop at this level in the view hierarchy, and no animation events should be dispatch to
the subtree of the view hierarchy.

<br />

Constant Value:

0
(0x00000000)


## Public constructors

### Callback

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

```
public Callback (int dispatchMode)
```

Creates a new `https://developer.android.com/reference/android/view/WindowInsetsAnimation` callback with the given
`https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()`.

<br />

| Parameters ||
|---|---|
| `dispatchMode` | `int`: The dispatch mode for this callback. See `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()`. Value is one of the following: - `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_STOP` - `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_CONTINUE_ON_SUBTREE` |

## Public methods

### getDispatchMode

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

```
public final int getDispatchMode ()
```

Retrieves the dispatch mode of this listener. Dispatch of the all animation events is
hierarchical: It will starts at the root of the view hierarchy and then traverse it and
invoke the callback of the specific `https://developer.android.com/reference/android/view/View` that is being traversed.
The method may return either `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_CONTINUE_ON_SUBTREE` to indicate that
animation events should be propagated to the subtree of the view hierarchy, or
`https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_STOP` to stop dispatching. In that case, all animation callbacks
related to the animation passed in will be stopped from propagating to the subtree of the
hierarchy.


Also note that `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_STOP` behaves the same way as
returning `https://developer.android.com/reference/android/view/WindowInsets#CONSUMED` during the regular insets dispatch in
`https://developer.android.com/reference/android/view/View#onApplyWindowInsets(android.view.WindowInsets)`.

<br />

| Returns ||
|---|---|
| `int` | Either `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_CONTINUE_ON_SUBTREE` to indicate that dispatching of animation events will continue to the subtree of the view hierarchy, or `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_STOP` to indicate that animation events will stop dispatching. Value is one of the following: - `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_STOP` - `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_CONTINUE_ON_SUBTREE` |

### onEnd

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

```
public void onEnd (WindowInsetsAnimation animation)
```

Called when an insets animation has ended.

<br />

| Parameters ||
|---|---|
| `animation` | `WindowInsetsAnimation`: The animation that has ended. This will be the same instance as passed into `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onStart(android.view.WindowInsetsAnimation,%20android.view.WindowInsetsAnimation.Bounds)` This value cannot be `null`. <br /> |

### onPrepare

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

```
public void onPrepare (WindowInsetsAnimation animation)
```

Called when an insets animation is about to start and before the views have been laid out
in the end state of the animation. The ordering of events during an insets animation is
the following:


- Application calls `https://developer.android.com/reference/android/view/WindowInsetsController#hide(int)`, `https://developer.android.com/reference/android/view/WindowInsetsController#show(int)`, `https://developer.android.com/reference/android/view/WindowInsetsController#controlWindowInsetsAnimation(int,%20long,%20android.view.animation.Interpolator,%20android.os.CancellationSignal,%20android.view.WindowInsetsAnimationControlListener)`
- onPrepare is called on the view hierarchy listeners
- `https://developer.android.com/reference/android/view/View#onApplyWindowInsets(android.view.WindowInsets)` will be called with the end state of the animation
- View hierarchy gets laid out according to the changes the application has requested due to the new insets being dispatched
- `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onStart(android.view.WindowInsetsAnimation,%20android.view.WindowInsetsAnimation.Bounds)` is called *before* the view hierarchy gets drawn in the new laid out state
- `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onProgress(android.view.WindowInsets,%20java.util.List<android.view.WindowInsetsAnimation>)` is called immediately after with the animation start state
- The frame gets drawn.


This ordering allows the application to inspect the end state after the animation has
finished, and then revert to the starting state of the animation in the first
`https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onProgress(android.view.WindowInsets,%20java.util.List<android.view.WindowInsetsAnimation>)` callback by using post-layout view properties like `https://developer.android.com/reference/android/view/View#setX(float)`
and related methods.

Note that the animation might be cancelled before `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onStart(android.view.WindowInsetsAnimation,%20android.view.WindowInsetsAnimation.Bounds)` is dispatched. On
`https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` and later, `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onEnd(android.view.WindowInsetsAnimation)` is immediately
dispatched without an `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onStart(android.view.WindowInsetsAnimation,%20android.view.WindowInsetsAnimation.Bounds)` in that case.
On `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R`, no callbacks are dispatched after
`#onPrepare` for such an animation.


Note: If the animation is application controlled by using
`https://developer.android.com/reference/android/view/WindowInsetsController#controlWindowInsetsAnimation(int,%20long,%20android.view.animation.Interpolator,%20android.os.CancellationSignal,%20android.view.WindowInsetsAnimationControlListener)`, the end state of the
animation is undefined as the application may decide on the end state only by passing in
`shown` parameter when calling `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#finish(boolean)`. In
this situation, the system will dispatch the insets in the opposite visibility state
before the animation starts. Example: When controlling the input method with
`https://developer.android.com/reference/android/view/WindowInsetsController#controlWindowInsetsAnimation(int,%20long,%20android.view.animation.Interpolator,%20android.os.CancellationSignal,%20android.view.WindowInsetsAnimationControlListener)` and the input method is
currently showing, `https://developer.android.com/reference/android/view/View#onApplyWindowInsets(android.view.WindowInsets)` will receive a `https://developer.android.com/reference/android/view/WindowInsets`
instance for which `https://developer.android.com/reference/android/view/WindowInsets#isVisible(int)` will return `false` for
`https://developer.android.com/reference/android/view/WindowInsets.Type#ime()`.

<br />

| Parameters ||
|---|---|
| `animation` | `WindowInsetsAnimation`: The animation that is about to start. This value cannot be `null`. <br /> |

### onProgress

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

```
public abstract WindowInsets onProgress (WindowInsets insets, 
                List<WindowInsetsAnimation> runningAnimations)
```

Called when the insets change as part of running an animation. Note that even if multiple
animations for different types are running, there will only be one progress callback per
frame. The `insets` passed as an argument represents the overall state and will
include all types, regardless of whether they are animating or not.


Note that insets dispatch is hierarchical: It will start at the root of the view
hierarchy, and then traverse it and invoke the callback of the specific `https://developer.android.com/reference/android/view/View`
being traversed. The method may return a modified instance by calling
`https://developer.android.com/reference/android/view/WindowInsets#inset(int,%20int,%20int,%20int)` to indicate that a part of the insets have
been used to offset or clip its children, and the children shouldn't worry about that
part anymore. Furthermore, if `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()` returns
`https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_STOP`, children of this view will not receive the callback anymore.

<br />

| Parameters ||
|---|---|
| `insets` | `WindowInsets`: The current insets. This value cannot be `null`. <br /> |
| `runningAnimations` | `List`: The currently running animations. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/WindowInsets` | The insets to dispatch to the subtree of the hierarchy. This value cannot be `null`. <br /> |

### onStart

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

```
public WindowInsetsAnimation.Bounds onStart (WindowInsetsAnimation animation, 
                WindowInsetsAnimation.Bounds bounds)
```

Called when an insets animation gets started.


Note that, like `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onProgress(android.view.WindowInsets,%20java.util.List<android.view.WindowInsetsAnimation>)`, dispatch of the animation start event is
hierarchical: It will starts at the root of the view hierarchy and then traverse it
and invoke the callback of the specific `https://developer.android.com/reference/android/view/View` that is being traversed.
The method may return a modified
instance of the bounds by calling `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Bounds#inset(android.graphics.Insets)` to indicate that a part of
the insets have been used to offset or clip its children, and the children shouldn't
worry about that part anymore. Furthermore, if `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#getDispatchMode()` returns
`https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#DISPATCH_MODE_STOP`, children of this view will not receive the callback anymore.

<br />

| Parameters ||
|---|---|
| `animation` | `WindowInsetsAnimation`: The animation that is about to start. This value cannot be `null`. <br /> |
| `bounds` | `WindowInsetsAnimation.Bounds`: The bounds in which animation happens. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Bounds` | The animation representing the part of the insets that should be dispatched to the subtree of the hierarchy. This value cannot be `null`. <br /> |