# WindowInsetsAnimationCompat

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) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

*** ** * ** ***

<br />

```
class WindowInsetsAnimationCompat
```

<br />

*** ** * ** ***

Class representing an animation of a set of windows that cause insets.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.BoundsCompat` Class representing the range of an `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat` |
| `abstract class https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback` Interface that allows the application to listen to animation events for windows that cause insets. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#WindowInsetsAnimationCompat(int,android.view.animation.Interpolator,long)( typeMask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, interpolator: https://developer.android.com/reference/android/view/animation/Interpolator.html?, durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Creates a new `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat` object. |

| ### Public functions |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#getAlpha()()` Retrieves the translucency of the windows that are animating. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#getDurationMillis()()` |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#getFraction()()` Returns the raw fractional progress of this animation between start state of the animation and the end state of the animation. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#getInterpolatedFraction()()` Returns the interpolated fractional progress of this animation between start state of the animation and the end state of the animation. |
| `https://developer.android.com/reference/android/view/animation/Interpolator.html?` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#getInterpolator()()` Retrieves the interpolator used for this animation, or `null` if this animation doesn't follow an interpolation curved. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#getTypeMask()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#setAlpha(float)(alpha: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Sets the translucency of the windows that are animating. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#setFraction(float)(fraction: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Set fraction of the progress if `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Type` animation is controlled by the app. |

## Public constructors

### WindowInsetsAnimationCompat

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

```
WindowInsetsAnimationCompat(
    typeMask: Int,
    interpolator: Interpolator?,
    durationMillis: Long
)
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat` object.

This should only be used for testing, as usually the system creates this object for the application to listen to with `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback`.

| Parameters |
|---|---|
| `typeMask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The bitmask of `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Type`s that are animating. |
| `interpolator: https://developer.android.com/reference/android/view/animation/Interpolator.html?` | The interpolator of the animation. |
| `durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration of the animation in `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html#MILLISECONDS`. |

## Public functions

### getAlpha

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

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

Retrieves the translucency of the windows that are animating.

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Alpha of windows that cause insets of type `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Type`. |

### getDurationMillis

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

```
fun getDurationMillis(): Long
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | duration of animation in `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html#MILLISECONDS`, or -1 if the animation doesn't have a fixed duration. |

### getFraction

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

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

Returns the raw fractional progress of this animation between start state of the animation and the end state of the animation. Note that this progress is the global progress of the animation, whereas `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onProgress(androidx.core.view.WindowInsetsCompat,java.util.List<androidx.core.view.WindowInsetsAnimationCompat>)` will only dispatch the insets that may be inset with `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat#inset(androidx.core.graphics.Insets)` by parents of views in the hierarchy. Progress per insets animation is global for the entire animation. One animation animates all things together (in, out, ...). If they don't animate together, we'd have multiple animations.

Note: In case the application is controlling the animation, the valued returned here will be the same as the application passed into `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)`.

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The current progress of this animation. |

### getInterpolatedFraction

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

```
fun getInterpolatedFraction(): Float
```

Returns the interpolated fractional progress of this animation between start state of the animation and the end state of the animation. Note that this progress is the global progress of the animation, whereas `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat.Callback#onProgress(androidx.core.view.WindowInsetsCompat,java.util.List<androidx.core.view.WindowInsetsAnimationCompat>)` will only dispatch the insets that may be inset with `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat#inset(androidx.core.graphics.Insets)` by parents of views in the hierarchy. Progress per insets animation is global for the entire animation. One animation animates all things together (in, out, ...). If they don't animate together, we'd have multiple animations.

Note: In case the application is controlling the animation, the valued returned here will be the same as the application passed into `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)`, interpolated with the interpolator passed into `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat#controlWindowInsetsAnimation(int,long,android.view.animation.Interpolator,android.os.CancellationSignal,androidx.core.view.WindowInsetsAnimationControlListenerCompat)`.

Note: For system-initiated animations, this will always return a valid value between 0 and 1.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The current interpolated progress of this animation. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#getFraction()` | for raw fraction. |

### getInterpolator

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

```
fun getInterpolator(): Interpolator?
```

Retrieves the interpolator used for this animation, or `null` if this animation doesn't follow an interpolation curved. For system-initiated animations, this will never return `null`.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/animation/Interpolator.html?` | The interpolator used for this animation. |

### getTypeMask

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

```
fun getTypeMask(): Int
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The bitmask of `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Type` that are animating. |

### setAlpha

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

```
fun setAlpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float): Unit
```

Sets the translucency of the windows that are animating.

Note: This should only be used for testing, as the system fills in the alpha for the application or the alpha that was passed into `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)` is being used.

| Parameters |
|---|---|
| `alpha: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Alpha of windows that cause insets of type `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Type`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#getAlpha()` |   |

### setFraction

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

```
fun setFraction(fraction: @FloatRange(from = 0.0, to = 1.0) Float): Unit
```

Set fraction of the progress if `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Type` animation is controlled by the app.

Note: This should only be used for testing, as the system fills in the fraction for the application or the fraction that was passed into `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)` is being used.

| Parameters |
|---|---|
| `fraction: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | fractional progress between 0 and 1 where 0 represents hidden and zero progress and 1 represent fully shown final state. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsAnimationCompat#getFraction()` |   |