# WindowCompat

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

*** ** * ** ***

<br />

```
class WindowCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/view/Window.html`.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowCompat#FEATURE_ACTION_BAR() = 8` Flag for enabling the Action Bar. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowCompat#FEATURE_ACTION_BAR_OVERLAY() = 9` Flag for requesting an Action Bar that overlays window content. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowCompat#FEATURE_ACTION_MODE_OVERLAY() = 10` Flag for specifying the behavior of action modes when an Action Bar is not present. |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowCompat#enableEdgeToEdge(android.view.Window)(window: https://developer.android.com/reference/android/view/Window.html)` Enables the content of the given `https://developer.android.com/reference/android/view/Window.html` to reach the edges of the window without getting inset by system insets, and prevents the framework from placing color views behind system bars. |
| `java-static https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowCompat#getInsetsController(android.view.Window,android.view.View)(window: https://developer.android.com/reference/android/view/Window.html, view: https://developer.android.com/reference/android/view/View.html)` Retrieves the single `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat` of the window this view is attached to. |
| `java-static T` | `<T : https://developer.android.com/reference/android/view/View.html?> https://developer.android.com/reference/kotlin/androidx/core/view/WindowCompat#requireViewById(android.view.Window,int)(window: https://developer.android.com/reference/android/view/Window.html, id: @https://developer.android.com/reference/kotlin/androidx/annotation/IdRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Finds a view that was identified by the `android:id` XML attribute that was processed in `https://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)`, or throws an IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/view/WindowCompat#setDecorFitsSystemWindows(android.view.Window,boolean)( window: https://developer.android.com/reference/android/view/Window.html, decorFitsSystemWindows: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Sets whether the decor view should fit root-level content views for `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat`. |

## Constants

### FEATURE_ACTION_BAR

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

```
const val FEATURE_ACTION_BAR = 8: Int
```

Flag for enabling the Action Bar. This is enabled by default for some devices. The Action Bar replaces the title bar and provides an alternate location for an on-screen menu button on some devices.

### FEATURE_ACTION_BAR_OVERLAY

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

```
const val FEATURE_ACTION_BAR_OVERLAY = 9: Int
```

Flag for requesting an Action Bar that overlays window content. Normally an Action Bar will sit in the space above window content, but if this feature is requested along with `https://developer.android.com/reference/kotlin/androidx/core/view/WindowCompat#FEATURE_ACTION_BAR()` it will be layered over the window content itself. This is useful if you would like your app to have more control over how the Action Bar is displayed, such as letting application content scroll beneath an Action Bar with a transparent background or otherwise displaying a transparent/translucent Action Bar over application content.

This mode is especially useful with `https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_FULLSCREEN`, which allows you to seamlessly hide the action bar in conjunction with other screen decorations.

As of `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#JELLY_BEAN`, when an ActionBar is in this mode it will adjust the insets provided to `https://developer.android.com/reference/android/view/View.html#fitSystemWindows(android.graphics.Rect)` to include the content covered by the action bar, so you can do layout within that space.

### FEATURE_ACTION_MODE_OVERLAY

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

```
const val FEATURE_ACTION_MODE_OVERLAY = 10: Int
```

Flag for specifying the behavior of action modes when an Action Bar is not present. If overlay is enabled, the action mode UI will be allowed to cover existing window content.

## Public functions

### enableEdgeToEdge

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

```
java-static fun enableEdgeToEdge(window: Window): Unit
```

Enables the content of the given `https://developer.android.com/reference/android/view/Window.html` to reach the edges of the window without getting inset by system insets, and prevents the framework from placing color views behind system bars.

| Parameters |
|---|---|
| `window: https://developer.android.com/reference/android/view/Window.html` | the given window. |

### getInsetsController

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

```
java-static fun getInsetsController(window: Window, view: View): WindowInsetsControllerCompat
```

Retrieves the single `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat` of the window this view is attached to.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat` | The `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsControllerCompat` for the window. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/Window.html#getInsetsController()` |   |

### requireViewById

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

```
java-static fun <T : View?> requireViewById(window: Window, id: @IdRes Int): T
```

Finds a view that was identified by the `android:id` XML attribute that was processed in `https://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)`, or throws an IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy.

**Note:** In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.

| Parameters |
|---|---|
| `window: https://developer.android.com/reference/android/view/Window.html` | window in which to find the view. |
| `id: @https://developer.android.com/reference/kotlin/androidx/annotation/IdRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the ID to search for |

| Returns |
|---|---|
| `T` | a view with given ID |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#requireViewById(android.view.View,int)` |   |
| `https://developer.android.com/reference/android/view/Window.html#findViewById(int)` |   |

### setDecorFitsSystemWindows

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

```
java-static fun setDecorFitsSystemWindows(
    window: Window,
    decorFitsSystemWindows: Boolean
): Unit
```

Sets whether the decor view should fit root-level content views for `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat`.

If set to `false`, the framework will not fit the content view to the insets and will just pass through the `https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat` to the content view.

Please note: using the `https://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int)` API in your app can conflict with this method. Please discontinue use of `https://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int)`.

| Parameters |
|---|---|
| `window: https://developer.android.com/reference/android/view/Window.html` | The current window. |
| `decorFitsSystemWindows: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the decor view should fit root-level content views for insets. |