# WindowInsetsAnimationCompat.Callback

# WindowInsetsAnimationCompat.Callback

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/view/WindowInsetsAnimationCompat.java+class:androidx.core.view.WindowInsetsAnimationCompat.Callback)  
Added in[1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationCompat.Callback "View this page in Java")

<br />

```
abstract class WindowInsetsAnimationCompat.Callback
```

<br />

*** ** * ** ***

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

## Summary

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DISPATCH_MODE_CONTINUE_ON_SUBTREE](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#DISPATCH_MODE_CONTINUE_ON_SUBTREE())` = 1` Return value for[getDispatchMode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#getDispatchMode()): Dispatching of animation events should continue in the view hierarchy.                                                              |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DISPATCH_MODE_STOP](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#DISPATCH_MODE_STOP())` = 0` Return value for[getDispatchMode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.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                                                                                                                                                                                                                                                           |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Callback](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#Callback(int))`(dispatchMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Creates a new[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat)callback with the given[dispatch mode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#getDispatchMode()). |

|                                                                  ### Public functions                                                                  |
|--------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                            | [getDispatchMode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#getDispatchMode())`()` Retrieves the dispatch mode of this listener.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                          | [onEnd](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onEnd(androidx.core.view.WindowInsetsAnimationCompat))`(animation: `[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat)`)` Called when an insets animation has ended.                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                          | [onPrepare](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onPrepare(androidx.core.view.WindowInsetsAnimationCompat))`(animation: `[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat)`)` Called when an insets animation is about to start and before the views have been re-laid out due to an animation.                                                                                                                                                                                                                                                                                                                                                    |
| `abstract `[WindowInsetsCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat)                                  | [onProgress](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onProgress(androidx.core.view.WindowInsetsCompat,java.util.List<androidx.core.view.WindowInsetsAnimationCompat>))`(` ` insets: `[WindowInsetsCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat)`,` ` runningAnimations: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat)`!>` `)` Called when the insets change as part of running an animation. |
| [WindowInsetsAnimationCompat.BoundsCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat) | [onStart](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onStart(androidx.core.view.WindowInsetsAnimationCompat,androidx.core.view.WindowInsetsAnimationCompat.BoundsCompat))`(` ` animation: `[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat)`,` ` bounds: `[WindowInsetsAnimationCompat.BoundsCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat) `)` Called when an insets animation gets started.                                                                                                                                                                                      |

## Constants

### DISPATCH_MODE_CONTINUE_ON_SUBTREE

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

```
const val DISPATCH_MODE_CONTINUE_ON_SUBTREE = 1: Int
```

Return value for[getDispatchMode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#getDispatchMode()): Dispatching of animation events should continue in the view hierarchy.  

### DISPATCH_MODE_STOP

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

```
const val DISPATCH_MODE_STOP = 0: Int
```

Return value for[getDispatchMode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.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

### Callback

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

```
Callback(dispatchMode: Int)
```

Creates a new[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat)callback with the given[dispatch mode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#getDispatchMode()).  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dispatchMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The dispatch mode for this callback. See[getDispatchMode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#getDispatchMode()). |

## Public functions

### getDispatchMode

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

```
fun getDispatchMode(): Int
```

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[View](https://developer.android.com/reference/android/view/View.html)that is being traversed. The method may return either[DISPATCH_MODE_CONTINUE_ON_SUBTREE](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#DISPATCH_MODE_CONTINUE_ON_SUBTREE())to indicate that animation events should be propagated to the subtree of the view hierarchy, or[DISPATCH_MODE_STOP](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.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[DISPATCH_MODE_STOP](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#DISPATCH_MODE_STOP())behaves the same way as returning[CONSUMED](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat#CONSUMED())during the regular insets dispatch in[onApplyWindowInsets](https://developer.android.com/reference/android/view/View.html#onApplyWindowInsets(android.view.WindowInsets)).  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Either[DISPATCH_MODE_CONTINUE_ON_SUBTREE](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#DISPATCH_MODE_CONTINUE_ON_SUBTREE())to indicate that dispatching of animation events will continue to the subtree of the view hierarchy, or[DISPATCH_MODE_STOP](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#DISPATCH_MODE_STOP())to indicate that animation events will stop dispatching. |

### onEnd

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

```
fun onEnd(animation: WindowInsetsAnimationCompat): Unit
```

Called when an insets animation has ended.  

|                                                                Parameters                                                                 |
|-------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `animation: `[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat) | The animation that has ended. This will be the same instance as passed into[onStart](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onStart(androidx.core.view.WindowInsetsAnimationCompat,androidx.core.view.WindowInsetsAnimationCompat.BoundsCompat)) |

### onPrepare

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

```
fun onPrepare(animation: WindowInsetsAnimationCompat): Unit
```

Called when an insets animation is about to start and before the views have been re-laid out due to an animation.

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[onProgress](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onProgress(androidx.core.view.WindowInsetsCompat,java.util.List<androidx.core.view.WindowInsetsAnimationCompat>))callback by using post-layout view properties like[setX](https://developer.android.com/reference/android/view/View.html#setX(float))and related methods.

The ordering of events during an insets animation is the following:

- Application calls[hide](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat#hide(int)),[show](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat#show(int)),[controlWindowInsetsAnimation](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat#controlWindowInsetsAnimation(int,long,android.view.animation.Interpolator,android.os.CancellationSignal,androidx.core.view.WindowInsetsAnimationControlListenerCompat))
- onPrepare is called on the view hierarchy listeners
- [onApplyWindowInsets](https://developer.android.com/reference/android/view/View.html#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
- [onStart](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onStart(androidx.core.view.WindowInsetsAnimationCompat,androidx.core.view.WindowInsetsAnimationCompat.BoundsCompat))is called*before*the view hierarchy gets drawn in the new laid out state
- [onProgress](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onProgress(androidx.core.view.WindowInsetsCompat,java.util.List<androidx.core.view.WindowInsetsAnimationCompat>))is called immediately after with the animation start state
- The frame gets drawn.

Note: If the animation is application controlled by using[controlWindowInsetsAnimation](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat#controlWindowInsetsAnimation(int,long,android.view.animation.Interpolator,android.os.CancellationSignal,androidx.core.view.WindowInsetsAnimationControlListenerCompat)), 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[finish](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#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[controlWindowInsetsAnimation](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat#controlWindowInsetsAnimation(int,long,android.view.animation.Interpolator,android.os.CancellationSignal,androidx.core.view.WindowInsetsAnimationControlListenerCompat))and the input method is currently showing,[onApplyWindowInsets](https://developer.android.com/reference/android/view/View.html#onApplyWindowInsets(android.view.WindowInsets))will receive a[WindowInsetsCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat)instance for which[isVisible](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat#isVisible(int))will return`false`for[ime](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Type#ime()).  

|                                                                Parameters                                                                 |
|-------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------|
| `animation: `[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat) | The animation that is about to start. |

### onProgress

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

```
abstract fun onProgress(
    insets: WindowInsetsCompat,
    runningAnimations: (Mutable)List<WindowInsetsAnimationCompat!>
): WindowInsetsCompat
```

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[View](https://developer.android.com/reference/android/view/View.html)being traversed. The method may return a modified instance by calling[inset](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat#inset(int,int,int,int))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[getDispatchMode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#getDispatchMode())returns[DISPATCH_MODE_STOP](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#DISPATCH_MODE_STOP()), children of this view will not receive the callback anymore.  

|                                                                                                                                                                        Parameters                                                                                                                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| `insets: `[WindowInsetsCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat)                                                                                                                                                                                                                                      | The current insets.               |
| `runningAnimations: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat)`!>` | The currently running animations. |

|                                                  Returns                                                   |
|------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [WindowInsetsCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat) | The insets to dispatch to the subtree of the hierarchy. |

### onStart

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

```
fun onStart(
    animation: WindowInsetsAnimationCompat,
    bounds: WindowInsetsAnimationCompat.BoundsCompat
): WindowInsetsAnimationCompat.BoundsCompat
```

Called when an insets animation gets started.

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[onProgress](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onProgress(androidx.core.view.WindowInsetsCompat,java.util.List<androidx.core.view.WindowInsetsAnimationCompat>))callback by using post-layout view properties like[setX](https://developer.android.com/reference/android/view/View.html#setX(float))and related methods.

The ordering of events during an insets animation is the following:

- Application calls[hide](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat#hide(int)),[show](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat#show(int)),[controlWindowInsetsAnimation](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat#controlWindowInsetsAnimation(int,long,android.view.animation.Interpolator,android.os.CancellationSignal,androidx.core.view.WindowInsetsAnimationControlListenerCompat))
- onPrepare is called on the view hierarchy listeners
- [onApplyWindowInsets](https://developer.android.com/reference/android/view/View.html#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
- [onStart](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onStart(androidx.core.view.WindowInsetsAnimationCompat,androidx.core.view.WindowInsetsAnimationCompat.BoundsCompat))is called*before*the view hierarchy gets drawn in the new laid out state
- [onProgress](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onProgress(androidx.core.view.WindowInsetsCompat,java.util.List<androidx.core.view.WindowInsetsAnimationCompat>))is called immediately after with the animation start state
- The frame gets drawn.

Note that, like[onProgress](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onProgress(androidx.core.view.WindowInsetsCompat,java.util.List<androidx.core.view.WindowInsetsAnimationCompat>)), 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[View](https://developer.android.com/reference/android/view/View.html)that is being traversed. The method may return a modified instance of the bounds by calling[inset](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat#inset(androidx.core.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[getDispatchMode](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#getDispatchMode())returns[DISPATCH_MODE_STOP](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#DISPATCH_MODE_STOP()), children of this view will not receive the callback anymore.  

|                                                                            Parameters                                                                            |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|
| `animation: `[WindowInsetsAnimationCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat)                        | The animation that is about to start.  |
| `bounds: `[WindowInsetsAnimationCompat.BoundsCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat) | The bounds in which animation happens. |

|                                                                        Returns                                                                         |
|--------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [WindowInsetsAnimationCompat.BoundsCompat](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat) | The animation bounds representing the part of the insets that should be dispatched to the subtree of the hierarchy. |