Use insets in Views and Compose
Stay organized with collections
Save and categorize content based on your preferences.
If your app contains both Compose and View code, you may need to be explicit
about which system insets each one should consume and ensure that insets are
dispatched to sibling views.
Overriding default insets
You may need to override default insets when your screen has both Views and
Compose code in the same hierarchy. In this case, you need to be explicit in
which one should consume the insets, and which one should ignore them.
For example, if your outermost layout is an Android View layout, you should
consume the insets in the View system and ignore them for Compose.
Alternatively, if your outermost layout is a composable, you should consume the
insets in Compose, and pad the AndroidView
composables accordingly.
By default, each ComposeView
consumes all insets at the
WindowInsetsCompat
level of consumption. To change this default behavior, set
AbstractComposeView.consumeWindowInsets
to false
.
Backward compatible inset dispatching for views
If your app contains Views code, you may need to confirm that insets are dispatched
to sibling views on devices that run Android 10 (API level 29) or lower. See the
edge-to-edge Views guide
for more information.
System bar icons
Calling enableEdgeToEdge
ensures system bar icon colors update when the device
theme changes.
While going edge-to-edge, you might need to manually update the system bar icon
colors so they contrast with your app's background. For example, to create light
status bar icons:
Kotlin
WindowCompat.getInsetsController(window, window.decorView)
.isAppearanceLightStatusBars = false
Java
WindowCompat.getInsetsController(window, window.getDecorView())
.setAppearanceLightStatusBars(false);
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-26 UTC."],[],[],null,["# Use insets in Views and Compose\n\nIf your app contains both Compose and View code, you may need to be explicit\nabout which system insets each one should consume and ensure that insets are\ndispatched to sibling views.\n\nOverriding default insets\n-------------------------\n\nYou may need to override default insets when your screen has both Views and\nCompose code in the same hierarchy. In this case, you need to be explicit in\nwhich one should consume the insets, and which one should ignore them.\n\nFor example, if your outermost layout is an Android View layout, you should\nconsume the insets in the View system and ignore them for Compose.\nAlternatively, if your outermost layout is a composable, you should consume the\ninsets in Compose, and pad the `AndroidView` composables accordingly.\n\nBy default, each `ComposeView` consumes all insets at the\n`WindowInsetsCompat` level of consumption. To change this default behavior, set\n[`AbstractComposeView.consumeWindowInsets`](/reference/kotlin/androidx/compose/ui/platform/AbstractComposeView#(androidx.compose.ui.platform.AbstractComposeView).consumeWindowInsets())\nto `false`.\n\nBackward compatible inset dispatching for views\n-----------------------------------------------\n\nIf your app contains Views code, you may need to confirm that insets are dispatched\nto sibling views on devices that run Android 10 (API level 29) or lower. See the\n[edge-to-edge Views guide](/develop/ui/views/layout/edge-to-edge#backward-compatible-dispatching)\nfor more information.\n\nSystem bar icons\n----------------\n\nCalling `enableEdgeToEdge` ensures system bar icon colors update when the device\ntheme changes.\n\nWhile going edge-to-edge, you might need to manually update the system bar icon\ncolors so they contrast with your app's background. For example, to create light\nstatus bar icons: \n\n### Kotlin\n\n```kotlin\nWindowCompat.getInsetsController(window, window.decorView)\n .isAppearanceLightStatusBars = false\n```\n\n### Java\n\n```java\nWindowCompat.getInsetsController(window, window.getDecorView())\n .setAppearanceLightStatusBars(false);\n```"]]