Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Puoi attivare la visualizzazione edge-to-edge nella tua app chiamando
enableEdgeToEdge.
Questo dovrebbe essere sufficiente per la maggior parte delle app. Questa guida descrive come attivare
la visualizzazione edge-to-edge se la tua app deve farlo senza utilizzare enableEdgeToEdge.
Quando funziona in un layout edge-to-edge, la tua app deve cambiare i colori
delle barre di sistema per rendere visibili i contenuti sottostanti. Dopo che la tua app
esegue questo passaggio, il sistema gestisce tutta la protezione visiva dell'interfaccia utente in modalità di navigazione tramite gesti e in modalità pulsante.
Modalità di navigazione tramite gesti:il sistema applica l'adattamento dinamico del colore in cui il colore dei contenuti delle barre di sistema cambia in base ai contenuti sottostanti. Nell'esempio seguente, il cursore nella barra di navigazione cambia in un
colore scuro quando si trova sopra contenuti chiari e in un colore chiaro quando si trova sopra
contenuti scuri.
Figura 1. Modifiche ai colori nella modalità di navigazione
tramite gesti.
Modalità pulsante:il sistema applica una maschera traslucida dietro le barre di sistema (per il livello API 29 o versioni successive) o una barra di sistema trasparente (per il livello API 28 o versioni precedenti).
Figura 2. Tela traslucida dietro le barre di sistema.
Colore contenuti barra di stato:controlla il colore dei contenuti della barra di stato, ad esempio l'ora e le icone.
Figura 3. Colore dei contenuti della barra di stato.
Puoi modificare il file themes.xml per impostare il colore della barra di navigazione e,
facoltativamente, per impostare la barra di stato come trasparente e il colore dei contenuti della barra di stato come
scuro.
Puoi utilizzare l'API
WindowInsetsController
direttamente, ma ti consigliamo vivamente di utilizzare la libreria di supporto
WindowInsetsControllerCompat
ove possibile. Puoi utilizzare l'API WindowInsetsControllerCompat anziché
theme.xml per controllare il colore dei contenuti della barra di stato. A questo scopo, utilizza la funzione
setAppearanceLightNavigationBars(), passando true per cambiare il colore del primo piano della navigazione in
un colore chiaro o false per ripristinare il colore predefinito.
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-08-27 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-08-27 UTC."],[],[],null,["You can enable the edge-to-edge display in your app by calling\n[`enableEdgeToEdge`](/reference/androidx/activity/ComponentActivity#(androidx.activity.ComponentActivity).enableEdgeToEdge(androidx.activity.SystemBarStyle,androidx.activity.SystemBarStyle)).\nThis should be sufficient for most apps. This guide describes how to enable\nedge-to-edge if your app needs to do so without using `enableEdgeToEdge`.\n\nLay out your app in full screen\n\nUse [`WindowCompat.setDecorFitsSystemWindows(window,\nfalse)`](/reference/androidx/core/view/WindowCompat#setDecorFitsSystemWindows(android.view.Window,%20boolean))\nto lay out your app behind the system bars, as shown in the following code\nexample: \n\nKotlin \n\n```kotlin\noverride fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n WindowCompat.setDecorFitsSystemWindows(window, false)\n}\n```\n\nJava \n\n```java\n@Override\npublic void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n WindowCompat.setDecorFitsSystemWindows(getWindow(), false);\n}\n```\n\nChange the color of the system bars\n\nWhen operating in an edge-to-edge layout, your app needs to change the colors of\nthe system bars to let the content underneath be visible. After your app\nperforms this step, the system handles all visual protection of the user\ninterface in gesture navigation mode and in button mode.\n\n- **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.\n\n**Figure 1.** Color changes in gesture navigation mode.\n\n- **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).\n\n**Figure 2.** Translucent scrim behind system bars.\n\n- **Status bar content color:** controls the color of status bar content, such as the time and icons.\n\n**Figure 3.** Status bar content color.\n\nYou can edit the `themes.xml` file to set the color of the navigation bar and,\noptionally, to set the status bar as transparent and status bar content color as\ndark. \n\n \u003c!-- values-v29/themes.xml --\u003e\n \u003cstyle name=\"Theme.MyApp\"\u003e\n \u003citem name=\"android:navigationBarColor\"\u003e\n @android:color/transparent\n \u003c/item\u003e\n\n \u003c!-- Optional: set to transparent if your app is drawing behind the status bar. --\u003e\n \u003citem name=\"android:statusBarColor\"\u003e\n @android:color/transparent\n \u003c/item\u003e\n\n \u003c!-- Optional: set for a light status bar with dark content. --\u003e\n \u003citem name=\"android:windowLightStatusBar\"\u003e\n true\n \u003c/item\u003e\n \u003c/style\u003e\n\n| **Note:** If you prefer to disable automatic content protection on Android 10 (API level 29) or later, set [`android:enforceNavigationBarContrast`](/reference/android/view/Window#isNavigationBarContrastEnforced()), [`android:enforceStatusBarContrast`](/reference/android/view/Window#isStatusBarContrastEnforced()), or both to `false` in your theme.\n\nYou can use the\n[`WindowInsetsController`](/reference/android/view/WindowInsetsController) API\ndirectly, but we strongly recommend using the Support Library\n[`WindowInsetsControllerCompat`](/reference/androidx/core/view/WindowInsetsControllerCompat)\nwhere possible. You can use the `WindowInsetsControllerCompat` API instead of\n`theme.xml` to control the status bar's content color. To do so, use the\n[`setAppearanceLightNavigationBars()`](/reference/androidx/core/view/WindowInsetsControllerCompat#setAppearanceLightNavigationBars(boolean))\nfunction, passing in `true` to change the foreground color of the navigation to\na light color or `false` to revert to the default color. \n\nKotlin \n\n```kotlin\nval windowInsetsController =\n ViewCompat.getWindowInsetsController(window.decorView)\n\nwindowInsetsController?.isAppearanceLightNavigationBars = true\n```\n\nJava \n\n```java\nWindowInsetsControllerCompat windowInsetsController =\n ViewCompat.getWindowInsetsController(getWindow().getDecorView());\nif (windowInsetsController == null) {\n return;\n}\n\nwindowInsetsController.setAppearanceLightNavigationBars(true);\n```"]]