In alcune situazioni potresti volere che la tua app mostri un messaggio rapido all'utente, senza necessariamente attendere una risposta. Ad esempio, quando un utente esegue un'azione come l'invio di un'email o l'eliminazione di un file, la tua app mostra una conferma rapida. Spesso l'utente non deve rispondere al messaggio. Il messaggio deve essere abbastanza in evidenza da essere visibile all'utente, ma non così in evidenza da impedirgli di utilizzare la tua app.
Android fornisce il
Snackbar
widget per questo caso d'uso comune. Un Snackbar fornisce un breve messaggio popup all'utente. L'attività corrente rimane visibile e interattiva mentre viene visualizzato il pulsante Snackbar. Dopo poco tempo, Snackbar si chiude automaticamente.
Questa documentazione mostra come utilizzare Snackbar per mostrare messaggi popup.
Figura 1. Un Snackbar
mostra un messaggio nella parte inferiore dell'attività, mentre il resto dell'attività è ancora utilizzabile.
Scopri come aggiungere un'azione a un messaggio, consentendo all'utente di rispondere.
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-07-26 UTC.
[null,null,["Ultimo aggiornamento 2025-07-26 UTC."],[],[],null,["# Pop-up messages overview\n\nTry the Compose way \nJetpack Compose is the recommended UI toolkit for Android. Learn how to add notifications in Compose. \n[Snackbar →](/develop/ui/compose/components/snackbar) \n\nThere are situations where you might want your app to show a quick message to the user, without\nnecessarily waiting for the user to respond. For example, when a user performs an action like\nsending an email or deleting a file, your app shows a quick confirmation to the user. Often, the\nuser doesn't need to respond to the message. The message needs to be prominent enough that the user\ncan see it, but not so prominent that it prevents the user from working with your app.\n\nAndroid provides the\n[Snackbar](/reference/com/google/android/material/snackbar/Snackbar)\nwidget for this common use case. A `Snackbar` provides a quick pop-up message to the\nuser. The current activity remains visible and interactive while the `Snackbar` is\ndisplayed. After a short time, the `Snackbar` automatically dismisses itself.\n\nThis documentation shows you how to use `Snackbar` to show pop-up messages. \n\n\n**Figure 1.** A `Snackbar`\nshows a message at the bottom of the\nactivity, and the rest of the activity is still usable.\n| **Note:** The `Snackbar` class supersedes [Toast](/reference/android/widget/Toast). While `Toast` is supported, `Snackbar` is the preferred way to display brief, transient messages to the user.\n\nAdditional resources\n--------------------\n\n\n**[Build and display a pop-up message](/develop/ui/views/notifications/snackbar/showing)**\n:\n Learn how to use a `Snackbar` to display\n a brief message to the user.\n\n\n**[Add an action to a message](/develop/ui/views/notifications/snackbar/action)**\n:\n Learn how to add an action to a message, letting the user respond to\n the message."]]