You can enable the edge-to-edge display in your app by calling
[`enableEdgeToEdge`](https://developer.android.com/reference/androidx/activity/ComponentActivity#(androidx.activity.ComponentActivity).enableEdgeToEdge(androidx.activity.SystemBarStyle,androidx.activity.SystemBarStyle)).
This should be sufficient for most apps. This guide describes how to enable
edge-to-edge if your app needs to do so without using `enableEdgeToEdge`.

## Lay out your app in full screen

Use [`WindowCompat.setDecorFitsSystemWindows(window,
false)`](https://developer.android.com/reference/androidx/core/view/WindowCompat#setDecorFitsSystemWindows(android.view.Window,%20boolean))
to lay out your app behind the system bars, as shown in the following code
example:  

### Kotlin

```kotlin
override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  WindowCompat.setDecorFitsSystemWindows(window, false)
}
```

### Java

```java
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
}
```

## Change the color of the system bars

When operating in an edge-to-edge layout, your app needs to change the colors of
the system bars to let the content underneath be visible. After your app
performs this step, the system handles all visual protection of the user
interface in gesture navigation mode and in button mode.

- **Gesture navigation mode:** the system applies dynamic color adaptation in which the contents of the system bars change color based on the content behind them. In the following example, the handle in the navigation bar changes to a dark color when it's above light content and to a light color when it's above dark content.

**Figure 1.** Color changes in gesture navigation mode.

- **Button mode:** the system applies a translucent [scrim](https://m2.material.io/design/environment/surfaces.html#attributes) behind the system bars (for API level 29 or later) or a transparent system bar (for API level 28 or earlier).

![An image showing translucent system bars](https://developer.android.com/static/images/guide/navigation/e2e-translucent-scrim.png) **Figure 2.** Translucent scrim behind system bars.

- **Status bar content color:** controls the color of status bar content, such as the time and icons.

![An image showin status bar content color](https://developer.android.com/static/images/guide/navigation/e2e-status-color.png) **Figure 3.** Status bar content color.

You can edit the `themes.xml` file to set the color of the navigation bar and,
optionally, to set the status bar as transparent and status bar content color as
dark.  

    <!-- values-v29/themes.xml -->
    <style name="Theme.MyApp">
      <item name="android:navigationBarColor">
         @android:color/transparent
      </item>

      <!-- Optional: set to transparent if your app is drawing behind the status bar. -->
      <item name="android:statusBarColor">
         @android:color/transparent
      </item>

      <!-- Optional: set for a light status bar with dark content. -->
      <item name="android:windowLightStatusBar">
        true
      </item>
    </style>

| **Note:** If you prefer to disable automatic content protection on Android 10 (API level 29) or later, set [`android:enforceNavigationBarContrast`](https://developer.android.com/reference/android/view/Window#isNavigationBarContrastEnforced()), [`android:enforceStatusBarContrast`](https://developer.android.com/reference/android/view/Window#isStatusBarContrastEnforced()), or both to `false` in your theme.

You can use the
[`WindowInsetsController`](https://developer.android.com/reference/android/view/WindowInsetsController) API
directly, but we strongly recommend using the Support Library
[`WindowInsetsControllerCompat`](https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat)
where possible. You can use the `WindowInsetsControllerCompat` API instead of
`theme.xml` to control the status bar's content color. To do so, use the
[`setAppearanceLightNavigationBars()`](https://developer.android.com/reference/androidx/core/view/WindowInsetsControllerCompat#setAppearanceLightNavigationBars(boolean))
function, passing in `true` to change the foreground color of the navigation to
a light color or `false` to revert to the default color.  

### Kotlin

```kotlin
val windowInsetsController =
      ViewCompat.getWindowInsetsController(window.decorView)

windowInsetsController?.isAppearanceLightNavigationBars = true
```

### Java

```java
WindowInsetsControllerCompat windowInsetsController =
      ViewCompat.getWindowInsetsController(getWindow().getDecorView());
if (windowInsetsController == null) {
    return;
}

windowInsetsController.setAppearanceLightNavigationBars(true);
```