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

# WindowInsetsController

*** ** * ** ***

` public interface WindowInsetsController `   
` `

|---|
| android.view.WindowInsetsController |

<br />

*** ** * ** ***

Interface to control windows that generate insets. For guidance, see [Hide system bars for immersive mode](https://developer.android.com/develop/ui/views/layout/immersive).

## Summary

| ### Nested classes ||
|---|---|
| ` interface` | `https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener` Listener to be notified when the set of controllable `https://developer.android.com/reference/android/view/WindowInsets.Type` controlled by a `https://developer.android.com/reference/android/view/WindowInsetsController` changes. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_CAPTION_BARS` When `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND` is set, changes the foreground color of the caption bars so that the items on the bar can be read clearly on light backgrounds. |
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_NAVIGATION_BARS` Changes the foreground color for light navigation bars so that the items on the bar can be read clearly. |
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_STATUS_BARS` Changes the foreground color for light status bars so that the items on the bar can be read clearly. |
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND` Makes the caption bar transparent. |
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_DEFAULT` The default option for `https://developer.android.com/reference/android/view/WindowInsetsController#setSystemBarsBehavior(int)`: Window would like to remain interactive when hiding navigation bars by calling `https://developer.android.com/reference/android/view/WindowInsetsController#hide(int)` or `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#setInsetsAndAlpha(android.graphics.Insets,%20float,%20float)`. |
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_SHOW_BARS_BY_SWIPE` *This constant was deprecated in API level 31. Use `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_DEFAULT` instead.* |
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_SHOW_BARS_BY_TOUCH` *This constant was deprecated in API level 31. This is not supported on Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` and later. Use `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_DEFAULT` or `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE` instead.* |
| `int` | `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE` Option for `https://developer.android.com/reference/android/view/WindowInsetsController#setSystemBarsBehavior(int)`: Window would like to remain interactive when hiding navigation bars by calling `https://developer.android.com/reference/android/view/WindowInsetsController#hide(int)` or `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#setInsetsAndAlpha(android.graphics.Insets,%20float,%20float)`. |

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/view/WindowInsetsController#addOnControllableInsetsChangedListener(android.view.WindowInsetsController.OnControllableInsetsChangedListener)(https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener listener) ` Adds a `https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener` to the window insets controller. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/WindowInsetsController#controlWindowInsetsAnimation(int,%20long,%20android.view.animation.Interpolator,%20android.os.CancellationSignal,%20android.view.WindowInsetsAnimationControlListener)(int types, long durationMillis, https://developer.android.com/reference/android/view/animation/Interpolator interpolator, https://developer.android.com/reference/android/os/CancellationSignal cancellationSignal, https://developer.android.com/reference/android/view/WindowInsetsAnimationControlListener 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. |
| ` abstract int` | ` https://developer.android.com/reference/android/view/WindowInsetsController#getSystemBarsAppearance()() ` Retrieves the requested appearance of system bars. |
| ` abstract int` | ` https://developer.android.com/reference/android/view/WindowInsetsController#getSystemBarsBehavior()() ` Retrieves the requested behavior of system bars. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/WindowInsetsController#hide(int)(int types) ` Makes a set of windows causing insets disappear. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/WindowInsetsController#removeOnControllableInsetsChangedListener(android.view.WindowInsetsController.OnControllableInsetsChangedListener)(https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener listener) ` Removes a `https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener` from the window insets controller. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/WindowInsetsController#setSystemBarsAppearance(int,%20int)(int appearance, int mask) ` Controls the appearance of system bars. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/WindowInsetsController#setSystemBarsBehavior(int)(int behavior) ` Controls the behavior of system bars. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/WindowInsetsController#show(int)(int types) ` Makes a set of windows that cause insets appear on screen. |

## Constants

### APPEARANCE_LIGHT_CAPTION_BARS

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

```
public static final int APPEARANCE_LIGHT_CAPTION_BARS
```

When `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND` is set, changes the foreground color of the caption bars so that the items on the bar can be read clearly on light backgrounds.

<br />

Constant Value: 256 (0x00000100)

### APPEARANCE_LIGHT_NAVIGATION_BARS

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

```
public static final int APPEARANCE_LIGHT_NAVIGATION_BARS
```

Changes the foreground color for light navigation bars so that the items on the bar can be read clearly.

<br />

Constant Value: 16 (0x00000010)

### APPEARANCE_LIGHT_STATUS_BARS

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

```
public static final int APPEARANCE_LIGHT_STATUS_BARS
```

Changes the foreground color for light status bars so that the items on the bar can be read clearly.

<br />

Constant Value: 8 (0x00000008)

### APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND

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

```
public static final int APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND
```

Makes the caption bar transparent.

<br />

Constant Value: 128 (0x00000080)

### BEHAVIOR_DEFAULT

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

```
public static final int BEHAVIOR_DEFAULT
```

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

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.

<br />

<br />

Constant Value: 1 (0x00000001)

### BEHAVIOR_SHOW_BARS_BY_SWIPE

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

```
public static final int BEHAVIOR_SHOW_BARS_BY_SWIPE
```

<br />

**This constant was deprecated in API level 31.**   

Use `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_DEFAULT` instead.

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

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.

<br />

<br />

Constant Value: 1 (0x00000001)

### BEHAVIOR_SHOW_BARS_BY_TOUCH

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

```
public static final int BEHAVIOR_SHOW_BARS_BY_TOUCH
```

<br />

**This constant was deprecated in API level 31.**   

This is not supported on Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` and later. Use `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_DEFAULT` or `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE` instead.

Option for `https://developer.android.com/reference/android/view/WindowInsetsController#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/android/view/WindowInsetsController#hide(int)` or `https://developer.android.com/reference/android/view/WindowInsetsAnimationController#setInsetsAndAlpha(android.graphics.Insets,%20float,%20float)`.

<br />

Constant Value: 0 (0x00000000)

### BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

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

```
public static final int BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
```

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

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.

<br />

<br />

Constant Value: 2 (0x00000002)

## Public methods

### addOnControllableInsetsChangedListener

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

```
public abstract void addOnControllableInsetsChangedListener (WindowInsetsController.OnControllableInsetsChangedListener listener)
```

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

<br />

| Parameters ||
|---|---|
| `listener` | `WindowInsetsController.OnControllableInsetsChangedListener`: The listener to add. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener`
- `https://developer.android.com/reference/android/view/WindowInsetsController#removeOnControllableInsetsChangedListener(android.view.WindowInsetsController.OnControllableInsetsChangedListener)`

### controlWindowInsetsAnimation

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

```
public abstract void controlWindowInsetsAnimation (int types, 
                long durationMillis, 
                Interpolator interpolator, 
                CancellationSignal cancellationSignal, 
                WindowInsetsAnimationControlListener 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.

<br />

| Parameters ||
|---|---|
| `types` | `int`: The `https://developer.android.com/reference/android/view/WindowInsets.Type`s the application has requested to control. Value is either `0` or a combination of the following: |
| `durationMillis` | `long`: Duration of animation in `https://developer.android.com/reference/java/util/concurrent/TimeUnit#MILLISECONDS`, or -1 if the animation doesn't have a predetermined duration. This value will be passed to `https://developer.android.com/reference/android/view/WindowInsetsAnimation#getDurationMillis()` <br /> |
| `interpolator` | `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/android/view/WindowInsetsAnimation#getInterpolator()` and used to calculate `https://developer.android.com/reference/android/view/WindowInsetsAnimation#getInterpolatedFraction()`. <br /> |
| `cancellationSignal` | `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. This value may be `null`. <br /> |
| `listener` | `WindowInsetsAnimationControlListener`: The `https://developer.android.com/reference/android/view/WindowInsetsAnimationControlListener` that gets called when the windows are ready to be controlled, among other callbacks. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsAnimation#getFraction()`
- `https://developer.android.com/reference/android/view/WindowInsetsAnimation#getInterpolatedFraction()`
- `https://developer.android.com/reference/android/view/WindowInsetsAnimation#getInterpolator()`
- `https://developer.android.com/reference/android/view/WindowInsetsAnimation#getDurationMillis()`

### getSystemBarsAppearance

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

```
public abstract int getSystemBarsAppearance ()
```

Retrieves the requested appearance of system bars.

<br />

| Returns ||
|---|---|
| `int` | The requested bitmask of system bar appearance controlled by this window. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_STATUS_BARS` - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_NAVIGATION_BARS` - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND` - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_CAPTION_BARS` |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsController#setSystemBarsAppearance(int,%20int)`
- `https://developer.android.com/reference/android/R.attr#windowLightStatusBar`
- `https://developer.android.com/reference/android/R.attr#windowLightNavigationBar`

### getSystemBarsBehavior

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

```
public abstract int getSystemBarsBehavior ()
```

Retrieves the requested behavior of system bars.

<br />

| Returns ||
|---|---|
| `int` | the system bar behavior controlled by this window. Value is one of the following: - `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_DEFAULT` - `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE` |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsController#setSystemBarsBehavior(int)`

### hide

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

```
public abstract 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#onApplyWindowInsets(android.view.WindowInsets)` and checking visibility with `https://developer.android.com/reference/android/view/WindowInsets#isVisible(int)`.

<br />

| Parameters ||
|---|---|
| `types` | `int`: A bitmask of `https://developer.android.com/reference/android/view/WindowInsets.Type` specifying what windows the app would like to make disappear. Value is either `0` or a combination of the following: |

### removeOnControllableInsetsChangedListener

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

```
public abstract void removeOnControllableInsetsChangedListener (WindowInsetsController.OnControllableInsetsChangedListener listener)
```

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

<br />

| Parameters ||
|---|---|
| `listener` | `WindowInsetsController.OnControllableInsetsChangedListener`: The listener to remove. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsController.OnControllableInsetsChangedListener`
- `https://developer.android.com/reference/android/view/WindowInsetsController#addOnControllableInsetsChangedListener(android.view.WindowInsetsController.OnControllableInsetsChangedListener)`

### setSystemBarsAppearance

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

```
public abstract void setSystemBarsAppearance (int appearance, 
                int mask)
```

Controls the appearance of system bars.

For example, the following statement adds `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_STATUS_BARS`:

```
setSystemBarsAppearance(APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS)
```
And the following statement clears it:

```
setSystemBarsAppearance(0, APPEARANCE_LIGHT_STATUS_BARS)
```

<br />

<br />

| Parameters ||
|---|---|
| `appearance` | `int`: Bitmask of appearance flags. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_STATUS_BARS` - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_NAVIGATION_BARS` - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND` - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_CAPTION_BARS` |
| `mask` | `int`: Specifies which flags of appearance should be changed. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_STATUS_BARS` - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_NAVIGATION_BARS` - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND` - `https://developer.android.com/reference/android/view/WindowInsetsController#APPEARANCE_LIGHT_CAPTION_BARS` |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsController#getSystemBarsAppearance()`

### setSystemBarsBehavior

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

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

Controls the behavior of system bars.

<br />

| Parameters ||
|---|---|
| `behavior` | `int`: Determines how the bars behave when being hidden by the application. Value is one of the following: - `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_DEFAULT` - `https://developer.android.com/reference/android/view/WindowInsetsController#BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE` |

**See also:**

- `https://developer.android.com/reference/android/view/WindowInsetsController#getSystemBarsBehavior()`

### show

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

```
public abstract 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#onApplyWindowInsets(android.view.WindowInsets)` and checking visibility with `https://developer.android.com/reference/android/view/WindowInsets#isVisible(int)`.

<br />

| Parameters ||
|---|---|
| `types` | `int`: A bitmask of `https://developer.android.com/reference/android/view/WindowInsets.Type` specifying what windows the app would like to make appear on screen. Value is either `0` or a combination of the following: |