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

# WindowInsetsAnimationController

*** ** * ** ***

` public interface WindowInsetsAnimationController `   
` `

|---|
| android.view.WindowInsetsAnimationController |

<br />

*** ** * ** ***

Controller for app-driven animation of system windows.

`WindowInsetsAnimationController` lets apps animate system windows such as the `https://developer.android.com/reference/android/inputmethodservice/InputMethodService`. 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 `https://developer.android.com/reference/android/view/WindowInsetsController#controlWindowInsetsAnimation(int,%20long,%20android.view.animation.Interpolator,%20android.os.CancellationSignal,%20android.view.WindowInsetsAnimationControlListener)`.

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#finish(boolean)(boolean shown) ` Finishes the animation, and leaves the windows shown or hidden. |
| ` abstract float` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#getCurrentAlpha()() ` Current alpha value of the window. |
| ` abstract float` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#getCurrentFraction()() ` Returns the progress as previously set by `fraction` in `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#setInsetsAndAlpha(android.graphics.Insets,%20float,%20float)` |
| ` abstract https://developer.android.com/reference/android/graphics/Insets` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#getCurrentInsets()() ` Retrieves the current insets. |
| ` abstract https://developer.android.com/reference/android/graphics/Insets` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#getHiddenStateInsets()() ` Retrieves the `https://developer.android.com/reference/android/graphics/Insets` when the windows this animation is controlling are fully hidden. |
| ` abstract https://developer.android.com/reference/android/graphics/Insets` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#getShownStateInsets()() ` Retrieves the `https://developer.android.com/reference/android/graphics/Insets` when the windows this animation is controlling are fully shown. |
| ` abstract int` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#getTypes()() ` |
| ` abstract boolean` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#isCancelled()() ` Returns whether this instance has been cancelled by the system, or by invoking the `https://developer.android.com/reference/android/os/CancellationSignal` passed into `https://developer.android.com/reference/android/view/WindowInsetsController#controlWindowInsetsAnimation(int,%20long,%20android.view.animation.Interpolator,%20android.os.CancellationSignal,%20android.view.WindowInsetsAnimationControlListener)`. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#isFinished()() ` Returns whether this instance has been finished by a call to `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#finish(boolean)`. |
| ` default boolean` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#isReady()() ` Returns whether this instance is ready to be used to control window insets. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/WindowInsetsAnimationController#setInsetsAndAlpha(android.graphics.Insets,%20float,%20float)(https://developer.android.com/reference/android/graphics/Insets insets, float alpha, float fraction) ` Modifies the insets for the frame being drawn by indirectly moving the windows around in the system that are causing window insets. |

## Public methods

### finish

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

```
public abstract void finish (boolean shown)
```

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

After invoking `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#finish(boolean)`, this instance is no longer `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#isReady()`.

Note: Finishing an animation implicitly `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#setInsetsAndAlpha(android.graphics.Insets,%20float,%20float)` according to the requested end state without any further animation.

<br />

| Parameters ||
|---|---|
| `shown` | `boolean`: if `true`, the windows will be shown after finishing the animation. Otherwise they will be hidden. <br /> |

### getCurrentAlpha

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

```
public abstract float getCurrentAlpha ()
```

Current alpha value of the window.

<br />

| Returns ||
|---|---|
| `float` | float value between 0 and 1. <br /> |

### getCurrentFraction

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

```
public abstract float getCurrentFraction ()
```

Returns the progress as previously set by `fraction` in `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#setInsetsAndAlpha(android.graphics.Insets,%20float,%20float)`

<br />

| Returns ||
|---|---|
| `float` | 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. . Value is between 0.0f and 1.0f inclusive |

### getCurrentInsets

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

```
public abstract Insets getCurrentInsets ()
```

Retrieves the current insets.

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/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. This value cannot be `null`. <br /> |

### getHiddenStateInsets

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

```
public abstract Insets getHiddenStateInsets ()
```

Retrieves the `https://developer.android.com/reference/android/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 `https://developer.android.com/reference/android/view/View#getRootView()`

If there are any animation listeners registered, this value is the same as `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Bounds#getLowerBound()` that is being be passed into the root view of the hierarchy.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Insets` | Insets when the windows this animation is controlling are fully hidden. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Bounds#getLowerBound()`

### getShownStateInsets

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

```
public abstract Insets getShownStateInsets ()
```

Retrieves the `https://developer.android.com/reference/android/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 `https://developer.android.com/reference/android/view/View#getRootView()`

If there are any animation listeners registered, this value is the same as `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Bounds#getUpperBound()` that is being passed into the root view of hierarchy.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Insets` | Insets when the windows this animation is controlling are fully shown. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Bounds#getUpperBound()`

### getTypes

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

```
public abstract int getTypes ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | The `https://developer.android.com/reference/android/view/WindowInsets.Type`s this object is currently controlling. Value is either `0` or a combination of the following: |

### isCancelled

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

```
public abstract boolean isCancelled ()
```

Returns whether this instance has been cancelled by the system, or by invoking the `https://developer.android.com/reference/android/os/CancellationSignal` passed into `https://developer.android.com/reference/android/view/WindowInsetsController#controlWindowInsetsAnimation(int,%20long,%20android.view.animation.Interpolator,%20android.os.CancellationSignal,%20android.view.WindowInsetsAnimationControlListener)`.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the instance is cancelled, `false` otherwise. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsAnimationControlListener#onCancelled(android.view.WindowInsetsAnimationController)`

### isFinished

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

```
public abstract boolean isFinished ()
```

Returns whether this instance has been finished by a call to `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#finish(boolean)`.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the instance is finished, `false` otherwise. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsAnimationControlListener#onFinished(android.view.WindowInsetsAnimationController)`

### isReady

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

```
public boolean isReady ()
```

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

Instances are ready when passed in `https://developer.android.com/reference/android/view/WindowInsetsAnimationControlListener#onReady(android.view.WindowInsetsAnimationController,%20int)` and stop being ready when it is either `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#isFinished()` or `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#isCancelled()`.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the instance is ready, `false` otherwise. <br /> |

### setInsetsAndAlpha

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

```
public abstract void setInsetsAndAlpha (Insets insets, 
                float alpha, 
                float fraction)
```

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 `https://developer.android.com/reference/android/view/View#getRootView()`

Also note that this will **not** inform the view system of a full inset change via `https://developer.android.com/reference/android/view/View#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 `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback` by calling `https://developer.android.com/reference/android/view/View#setWindowInsetsAnimationCallback(android.view.WindowInsetsAnimation.Callback)` that will be notified about any insets change via `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback#onProgress(android.view.WindowInsets,%20java.util.List<android.view.WindowInsetsAnimation>)` during the animation.

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

<br />

| Parameters ||
|---|---|
| `insets` | `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 `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#getHiddenStateInsets()` to `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#getShownStateInsets()`. If you intend on changing alpha only, pass null or `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#getCurrentInsets()`. <br /> |
| `alpha` | `float`: The new alpha to apply to the inset side. Value is between 0.0f and 1.0f inclusive <br /> |
| `fraction` | `float`: instantaneous animation progress. This value is dispatched to `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback`. Value is between 0.0f and 1.0f inclusive <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback`
- `https://developer.android.com/reference/android/view/View#setWindowInsetsAnimationCallback(android.view.WindowInsetsAnimation.Callback)`