# WindowInsetsControllerCompat

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

*** ** * ** ***


```
public final class WindowInsetsControllerCompat
```

<br />

*** ** * ** ***

Provide simple controls of windows that generate insets. For SDKs \>= 30, this class is a simple wrapper around `https://developer.android.com/reference/android/view/WindowInsetsController.html`. For lower SDKs, this class aims to behave as close as possible to the original implementation.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat.OnControllableInsetsChangedListener` Listener to be notified when the set of controllable `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type` controlled by a `https://developer.android.com/reference/android/view/WindowInsetsController.html` changes. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#BEHAVIOR_DEFAULT() = 1` The default option for `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setSystemBarsBehavior(int)`: Window would like to remain interactive when hiding navigation bars by calling `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#hide(int)` or `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)`. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#BEHAVIOR_SHOW_BARS_BY_SWIPE() = 1` **This field is deprecated.** Use `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#BEHAVIOR_DEFAULT()` instead. <br /> |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#BEHAVIOR_SHOW_BARS_BY_TOUCH() = 0` **This field is deprecated.** This is not supported on Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#S` and later. <br /> |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE() = 2` Option for `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setSystemBarsBehavior(int)`: Window would like to remain interactive when hiding navigation bars by calling `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#hide(int)` or `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#WindowInsetsControllerCompat(android.view.Window,android.view.View)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Window.html window, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html view)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#addOnControllableInsetsChangedListener(androidx.core.view.WindowInsetsControllerCompat.OnControllableInsetsChangedListener)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat.OnControllableInsetsChangedListener listener )` Adds a `https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener.html` to the window insets controller. |
| `void` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#controlWindowInsetsAnimation(int,long,android.view.animation.Interpolator,android.os.CancellationSignal,androidx.core.view.WindowInsetsAnimationControlListenerCompat)( int types, long durationMillis, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/animation/Interpolator.html interpolator, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/CancellationSignal.html cancellationSignal, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControlListenerCompat listener )` Lets the application control window inset animations in a frame-by-frame manner by modifying the position of the windows in the system causing insets directly using `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)` in the controller provided by the given listener. |
| `int` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#getSystemBarsBehavior()()` Retrieves the requested behavior of system bars. |
| `void` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#hide(int)(int types)` Makes a set of windows causing insets disappear. |
| `boolean` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#isAppearanceLightNavigationBars()()` Checks if the foreground of the navigation bar is set to light. |
| `boolean` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#isAppearanceLightStatusBars()()` Checks if the foreground of the status bar is set to light. |
| `void` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#removeOnControllableInsetsChangedListener(androidx.core.view.WindowInsetsControllerCompat.OnControllableInsetsChangedListener)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat.OnControllableInsetsChangedListener listener )` Removes a `https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener.html` from the window insets controller. |
| `void` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setAppearanceLightNavigationBars(boolean)(boolean isLight)` If true, changes the foreground color of the navigation bars to light so that the items on the bar can be read clearly. |
| `void` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setAppearanceLightStatusBars(boolean)(boolean isLight)` If true, changes the foreground color of the status bars to light so that the items on the bar can be read clearly. |
| `void` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setSystemBarsBehavior(int)(int behavior)` Controls the behavior of system bars. |
| `void` | `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#show(int)(int types)` Makes a set of windows that cause insets appear on screen. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 30) [toWindowInsetsControllerCompat](https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#toWindowInsetsControllerCompat(android.view.WindowInsetsController))( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/WindowInsetsController.html insetsController )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/core/view/WindowCompat#getInsetsController(android.view.Window,android.view.View)` instead <br /> |

## Constants

### BEHAVIOR_DEFAULT

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

```
public static final int BEHAVIOR_DEFAULT = 1
```

The default option for `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setSystemBarsBehavior(int)`: Window would like to remain interactive when hiding navigation bars by calling `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#hide(int)` or `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)`.

When system bars are hidden in this mode, they can be revealed with system gestures, such as swiping from the edge of the screen where the bar is hidden from.

When the gesture navigation is enabled, the system gestures can be triggered regardless the visibility of system bars.

### BEHAVIOR_SHOW_BARS_BY_SWIPE

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

```
public static final int BEHAVIOR_SHOW_BARS_BY_SWIPE = 1
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#BEHAVIOR_DEFAULT()` instead.

Option for `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setSystemBarsBehavior(int)`: Window would like to remain interactive when hiding navigation bars by calling `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#hide(int)` or `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)`.

When system bars are hidden in this mode, they can be revealed with system gestures, such as swiping from the edge of the screen where the bar is hidden from.

### BEHAVIOR_SHOW_BARS_BY_TOUCH

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

```
public static final int BEHAVIOR_SHOW_BARS_BY_TOUCH = 0
```

> [!CAUTION]
> **This field is deprecated.**   
>
> This is not supported on Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#S` and later. Use `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#BEHAVIOR_DEFAULT()` or `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE()` instead.

Option for `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setSystemBarsBehavior(int)`. System bars will be forcibly shown on any user interaction on the corresponding display if navigation bars are hidden by `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#hide(int)` or `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)`.

### BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

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

```
public static final int BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE = 2
```

Option for `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setSystemBarsBehavior(int)`: Window would like to remain interactive when hiding navigation bars by calling `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#hide(int)` or `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)`.

When system bars are hidden in this mode, they can be revealed temporarily with system gestures, such as swiping from the edge of the screen where the bar is hidden from. These transient system bars will overlay app's content, may have some degree of transparency, and will automatically hide after a short timeout.

## Public constructors

### WindowInsetsControllerCompat

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

```
public WindowInsetsControllerCompat(@NonNull Window window, @NonNull View view)
```

## Public methods

### addOnControllableInsetsChangedListener

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

```
public void addOnControllableInsetsChangedListener(
    @NonNull WindowInsetsControllerCompat.OnControllableInsetsChangedListener listener
)
```

Adds a `https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener.html` to the window insets controller.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat.OnControllableInsetsChangedListener listener` | The listener to add. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat.OnControllableInsetsChangedListener` |   |
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#removeOnControllableInsetsChangedListener(androidx.core.view.WindowInsetsControllerCompat.OnControllableInsetsChangedListener)` |   |

### controlWindowInsetsAnimation

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

```
public void controlWindowInsetsAnimation(
    int types,
    long durationMillis,
    @Nullable Interpolator interpolator,
    @Nullable CancellationSignal cancellationSignal,
    @NonNull WindowInsetsAnimationControlListenerCompat listener
)
```

Lets the application control window inset animations in a frame-by-frame manner by modifying the position of the windows in the system causing insets directly using `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControllerCompat#setInsetsAndAlpha(androidx.core.graphics.Insets,float,float)` in the controller provided by the given listener.

This method only works on API \>= 30 since there is no way to control the window in the system on prior APIs.

| Parameters |
|---|---|
| `int types` | The `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type`s the application has requested to control. |
| `long durationMillis` | Duration of animation in `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html#MILLISECONDS`, or -1 if the animation doesn't have a predetermined duration. This value will be passed to `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationCompat#getDurationMillis()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/animation/Interpolator.html interpolator` | The interpolator used for this animation, or `null ` if this animation doesn't follow an interpolation curve. This value will be passed to `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationCompat#getInterpolator()` and used to calculate `https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationCompat#getInterpolatedFraction()`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/CancellationSignal.html cancellationSignal` | A cancellation signal that the caller can use to cancel the request to obtain control, or once they have control, to cancel the control. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/WindowInsetsAnimationControlListenerCompat listener` | The `https://developer.android.com/reference/android/view/WindowInsetsAnimationControlListener.html` that gets called when the windows are ready to be controlled, among other callbacks. |

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

### getSystemBarsBehavior

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

```
public int getSystemBarsBehavior()
```

Retrieves the requested behavior of system bars.

| Returns |
|---|---|
| `int` | the system bar behavior controlled by this window. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setSystemBarsBehavior(int)` |   |

### hide

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

```
public void hide(int types)
```

Makes a set of windows causing insets disappear.

Note that if the window currently doesn't have control over a certain type, it will apply the change as soon as the window gains control. The app can listen to the event by observing `https://developer.android.com/reference/android/view/View.html#onApplyWindowInsets(android.view.WindowInsets)` and checking visibility with `https://developer.android.com/reference/android/view/WindowInsets.html#isVisible(int)`.

| Parameters |
|---|---|
| `int types` | A bitmask of `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type` specifying what windows the app would like to make disappear. |

### isAppearanceLightNavigationBars

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

```
public boolean isAppearanceLightNavigationBars()
```

Checks if the foreground of the navigation bar is set to light.

This method always returns false on API \<26.

If this value is being set in the theme (via `https://developer.android.com/reference/android/R.attr.html#windowLightNavigationBar`), then the correct value will only be returned once attached to the window.

Once this method is called, modifying \`systemUiVisibility\` directly to change the appearance is undefined behavior.

| Returns |
|---|---|
| `boolean` | true if the foreground is light |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setAppearanceLightNavigationBars(boolean)` |   |

### isAppearanceLightStatusBars

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

```
public boolean isAppearanceLightStatusBars()
```

Checks if the foreground of the status bar is set to light.

If this value is being set in the theme (via `https://developer.android.com/reference/android/R.attr.html#windowLightStatusBar`), then the correct value will only be returned once attached to the window.

Once this method is called, modifying \`systemUiVisibility\` directly to change the appearance is undefined behavior.

| Returns |
|---|---|
| `boolean` | true if the foreground is light |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setAppearanceLightStatusBars(boolean)` |   |

### removeOnControllableInsetsChangedListener

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

```
public void removeOnControllableInsetsChangedListener(
    @NonNull WindowInsetsControllerCompat.OnControllableInsetsChangedListener listener
)
```

Removes a `https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener.html` from the window insets controller.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat.OnControllableInsetsChangedListener listener` | The listener to remove. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat.OnControllableInsetsChangedListener` |   |
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#addOnControllableInsetsChangedListener(androidx.core.view.WindowInsetsControllerCompat.OnControllableInsetsChangedListener)` |   |

### setAppearanceLightNavigationBars

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

```
public void setAppearanceLightNavigationBars(boolean isLight)
```

If true, changes the foreground color of the navigation bars to light so that the items on the bar can be read clearly. If false, reverts to the default appearance.

This method has no effect on API \<26.

Once this method is called, modifying \`systemUiVisibility\` directly to change the appearance is undefined behavior.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#isAppearanceLightNavigationBars()` |   |

### setAppearanceLightStatusBars

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

```
public void setAppearanceLightStatusBars(boolean isLight)
```

If true, changes the foreground color of the status bars to light so that the items on the bar can be read clearly. If false, reverts to the default appearance.

Once this method is called, modifying \`systemUiVisibility\` directly to change the appearance is undefined behavior.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#isAppearanceLightStatusBars()` |   |

### setSystemBarsBehavior

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

```
public void setSystemBarsBehavior(int behavior)
```

Controls the behavior of system bars.

| Parameters |
|---|---|
| `int behavior` | Determines how the bars behave when being hidden by the application. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#getSystemBarsBehavior()` |   |

### show

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

```
public void show(int types)
```

Makes a set of windows that cause insets appear on screen.

Note that if the window currently doesn't have control over a certain type, it will apply the change as soon as the window gains control. The app can listen to the event by observing `https://developer.android.com/reference/android/view/View.html#onApplyWindowInsets(android.view.WindowInsets)` and checking visibility with `https://developer.android.com/reference/android/view/WindowInsets.html#isVisible(int)`.

| Parameters |
|---|---|
| `int types` | A bitmask of `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type` specifying what windows the app would like to make appear on screen. |

### toWindowInsetsControllerCompat

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

```
@RequiresApi(value = 30)
public static @NonNull WindowInsetsControllerCompat [toWindowInsetsControllerCompat](https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#toWindowInsetsControllerCompat(android.view.WindowInsetsController))(
    @NonNull WindowInsetsController insetsController
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/core/view/WindowCompat#getInsetsController(android.view.Window,android.view.View)` instead

Wrap a `https://developer.android.com/reference/android/view/WindowInsetsController.html` into a `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat` for compatibility purpose.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/WindowInsetsController.html insetsController` | The `https://developer.android.com/reference/android/view/WindowInsetsController.html` to wrap. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat` | The provided `https://developer.android.com/reference/android/view/WindowInsetsController.html` wrapped into a `https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat` |