# WindowInsetsAnimationControllerCompat

# WindowInsetsAnimationControllerCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/view/WindowInsetsAnimationControllerCompat.java+class:androidx.core.view.WindowInsetsAnimationControllerCompat)  
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/WindowInsetsAnimationControllerCompat "View this page in Java")

<br />

```
class WindowInsetsAnimationControllerCompat
```

<br />

*** ** * ** ***

Controller for app-driven animation of system windows.

`WindowInsetsAnimationController`lets apps animate system windows such as the[IME](https://developer.android.com/reference/android/inputmethodservice/InputMethodService.html). The animation is synchronized, such that changes the system windows and the app's current frame are rendered at the same time.

Control is obtained through[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)).

## Summary

|                                                                                          ### Public functions                                                                                          |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                          | [finish](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#finish(boolean))`(shown: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Finishes the animation, and leaves the windows shown or hidden.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                                                                                        | [getCurrentAlpha](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#getCurrentAlpha())`()` Current alpha value of the window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `@`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0, to = 1.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [getCurrentFraction](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#getCurrentFraction())`()` Returns the progress as previously set by`fraction`in[setInsetsAndAlpha](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float))                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets)                                                                                                                 | [getCurrentInsets](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#getCurrentInsets())`()` Retrieves the current insets.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets)                                                                                                                 | [getHiddenStateInsets](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#getHiddenStateInsets())`()` Retrieves the[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets)when the windows this animation is controlling are fully hidden.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets)                                                                                                                 | [getShownStateInsets](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#getShownStateInsets())`()` Retrieves the[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets)when the windows this animation is controlling are fully shown.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                            | [getTypes](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#getTypes())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                    | [isCancelled](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#isCancelled())`()` Returns whether this instance has been cancelled by the system, or by invoking the[android.os.CancellationSignal](https://developer.android.com/reference/android/os/CancellationSignal.html)passed into[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)).                                                                                                                                                                                                                        |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                    | [isFinished](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#isFinished())`()` Returns whether this instance has been finished by a call to[finish](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#finish(boolean)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                    | [isReady](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#isReady())`()` Returns whether this instance is ready to be used to control window insets.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                          | [setInsetsAndAlpha](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float))`(` ` insets: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets)`?,` ` alpha: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0, to = 1.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` fraction: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0, to = 1.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) `)` Modifies the insets for the frame being drawn by indirectly moving the windows around in the system that are causing window insets. |

## Public functions

### finish

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

```
fun finish(shown: Boolean): Unit
```

Finishes the animation, and leaves the windows shown or hidden.

After invoking[finish](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#finish(boolean)), this instance is no longer[ready](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#isReady()).

Note: Finishing an animation implicitly[sets insets and alpha](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float))according to the requested end state without any further animation.  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| `shown: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | if`true`, the windows will be shown after finishing the animation. Otherwise they will be hidden. |

### getCurrentAlpha

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

```
fun getCurrentAlpha(): Float
```

Current alpha value of the window.  

|                                     Returns                                     |
|---------------------------------------------------------------------------------|------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | float value between 0 and 1. |

### getCurrentFraction

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

```
fun getCurrentFraction(): @FloatRange(from = 0.0, to = 1.0) Float
```

Returns the progress as previously set by`fraction`in[setInsetsAndAlpha](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float))  

|                                                                                                Returns                                                                                                 |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `@`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0, to = 1.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | the progress of the animation, where`0`is fully hidden and`1`is fully shown. Note: this value represents raw overall progress of the animation i.e. the combined progress of insets and alpha. |

### getCurrentInsets

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

```
fun getCurrentInsets(): Insets
```

Retrieves the current insets.

Note that these insets are always relative to the window, which is the same as being relative to[getRootView](https://developer.android.com/reference/android/view/View.html#getRootView())  

|                                        Returns                                         |
|----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | The current insets on the currently showing frame. These insets will change as the animation progresses to reflect the current insets provided by the controlled window. |

### getHiddenStateInsets

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

```
fun getHiddenStateInsets(): Insets
```

Retrieves the[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets)when the windows this animation is controlling are fully hidden.

Note that these insets are always relative to the window, which is the same as being relative to[getRootView](https://developer.android.com/reference/android/view/View.html#getRootView())

If there are any animation listeners registered, this value is the same as[getLowerBound](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat#getLowerBound())that is being be passed into the root view of the hierarchy.  

|                                        Returns                                         |
|----------------------------------------------------------------------------------------|-------------------------------------------------------------------------|
| [Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | Insets when the windows this animation is controlling are fully hidden. |

|                                                                  See also                                                                   |
|---------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getLowerBound](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat#getLowerBound()) |   |

### getShownStateInsets

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

```
fun getShownStateInsets(): Insets
```

Retrieves the[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets)when the windows this animation is controlling are fully shown.

Note that these insets are always relative to the window, which is the same as being relative to[getRootView](https://developer.android.com/reference/android/view/View.html#getRootView())

If there are any animation listeners registered, this value is the same as[getUpperBound](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat#getUpperBound())that is being passed into the root view of hierarchy.  

|                                        Returns                                         |
|----------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | Insets when the windows this animation is controlling are fully shown. |

|                                                                  See also                                                                   |
|---------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getUpperBound](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat#getUpperBound()) |   |

### getTypes

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

```
fun getTypes(): Int
```  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The[Type](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Type)s this object is currently controlling. |

### isCancelled

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

```
fun isCancelled(): Boolean
```

Returns whether this instance has been cancelled by the system, or by invoking the[android.os.CancellationSignal](https://developer.android.com/reference/android/os/CancellationSignal.html)passed into[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)).  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if the instance is cancelled,`false`otherwise. |

|                                                                                             See also                                                                                              |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [onCancelled](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControlListenerCompat#onCancelled(androidx.core.view.WindowInsetsAnimationControllerCompat)) |   |

### isFinished

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

```
fun isFinished(): Boolean
```

Returns whether this instance has been finished by a call to[finish](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#finish(boolean)).  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-----------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if the instance is finished,`false`otherwise. |

|                                                                                            See also                                                                                             |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [onFinished](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControlListenerCompat#onFinished(androidx.core.view.WindowInsetsAnimationControllerCompat)) |   |

### isReady

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

```
fun isReady(): Boolean
```

Returns whether this instance is ready to be used to control window insets.

Instances are ready when passed in[onReady](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControlListenerCompat#onReady(androidx.core.view.WindowInsetsAnimationControllerCompat,int))and stop being ready when it is either[finished](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#isFinished())or[cancelled](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#isCancelled()).  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|--------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if the instance is ready,`false`otherwise. |

### setInsetsAndAlpha

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

```
fun setInsetsAndAlpha(
    insets: Insets?,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    fraction: @FloatRange(from = 0.0, to = 1.0) Float
): Unit
```

Modifies the insets for the frame being drawn by indirectly moving the windows around in the system that are causing window insets.

Note that these insets are always relative to the window, which is the same as being relative to[getRootView](https://developer.android.com/reference/android/view/View.html#getRootView())

Also note that this will**not** inform the view system of a full inset change via[dispatchApplyWindowInsets](https://developer.android.com/reference/android/view/View.html#dispatchApplyWindowInsets(android.view.WindowInsets))in order to avoid a full layout pass during the animation. If you'd like to animate views during a window inset animation, register a[WindowInsetsAnimationCompat.Callback](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback)by calling[setWindowInsetsAnimationCallback](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#setWindowInsetsAnimationCallback(android.view.View,androidx.core.view.WindowInsetsAnimationCompat.Callback))that will be notified about any insets change via[onProgress](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onProgress(androidx.core.view.WindowInsetsCompat,java.util.List<androidx.core.view.WindowInsetsAnimationCompat>))during the animation.

[dispatchApplyWindowInsets](https://developer.android.com/reference/android/view/View.html#dispatchApplyWindowInsets(android.view.WindowInsets))will instead be called once the animation has finished, i.e. once[finish](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#finish(boolean))has been called. Note: If there are no insets, alpha animation is still applied.  

|                                                                                                    Parameters                                                                                                    |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `insets: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets)`?`                                                                                                              | The new insets to apply. Based on the requested insets, the system will calculate the positions of the windows in the system causing insets such that the resulting insets of that configuration will match the passed in parameter. Note that these insets are being clamped to the range from[getHiddenStateInsets](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#getHiddenStateInsets())to[getShownStateInsets](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#getShownStateInsets()). If you intend on changing alpha only, pass null or[getCurrentInsets](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#getCurrentInsets()). |
| `alpha: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0, to = 1.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)    | The new alpha to apply to the inset side.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `fraction: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0, to = 1.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | instantaneous animation progress. This value is dispatched to[WindowInsetsAnimationCompat.Callback](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

|                                                                                                           See also                                                                                                           |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [WindowInsetsAnimationCompat.Callback](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback)                                                                               |   |
| [setWindowInsetsAnimationCallback](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#setWindowInsetsAnimationCallback(android.view.View,androidx.core.view.WindowInsetsAnimationCompat.Callback)) |   |