Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

# ViewTreeObserver.WindowInsetsAnimationListener

*** ** * ** ***


`
public
static


interface
ViewTreeObserver.WindowInsetsAnimationListener
`


`


`

|---|
| android.view.ViewTreeObserver.WindowInsetsAnimationListener |

<br />

*** ** * ** ***

Interface definition for a callback to be invoked when window insets animations prepare or
end.


A window insets animation listener can be registered to observe when window insets
animations are about to start (prepare) and when they end. These callbacks are executed on
the UI thread.


Unlike `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback`, which is designed for applications to
synchronize their view layouts or draw frames with the animation on every frame, this
listener only observes the preparation and completion of animations, but doesn't allow for
frame-by-frame synchronization.


Because this listener does not perform frame-by-frame synchronization, registering only
this listener without a corresponding `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback` on the view
hierarchy allows the window insets animation to run off-thread on the background animation
thread. This avoids the performance overhead of running the animation on the main UI
thread.


This listener does not have an equivalent to
`https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onStart(android.view.WindowInsetsAnimation,%20android.view.WindowInsetsAnimation.Bounds)` or receive the animation bounds,
because it is not intended for layout synchronization. To perform frame-synchronized layout
changes or customize the animation bounds, register a `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback`
on the view hierarchy instead.
**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback`

## Summary

| ### Public methods ||
|---|---|
| ` default void` | ` https://developer.android.com/reference/android/view/ViewTreeObserver.WindowInsetsAnimationListener#onEnd(android.view.WindowInsetsAnimation)(https://developer.android.com/reference/android/view/WindowInsetsAnimation animation) ` Called after a window insets animation has ended. |
| ` default void` | ` https://developer.android.com/reference/android/view/ViewTreeObserver.WindowInsetsAnimationListener#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. |

## Public methods

### onEnd

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

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

Called after a window insets animation has ended.

<br />

| Parameters ||
|---|---|
| `animation` | `WindowInsetsAnimation`: The animation that has ended. This value cannot be `null`. <br /> |

### onPrepare

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
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.


This is called before the final insets are dispatched to the view hierarchy via
`https://developer.android.com/reference/android/view/View#onApplyWindowInsets(android.view.WindowInsets)` or `https://developer.android.com/reference/android/view/View.OnApplyWindowInsetsListener`.

<br />

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