SnackBar Vs Toast
After Material Design was introduced in Android, lot many changes happened to Android UI components. Few of the existing components were enhanced and few new components were introduced for stunning UI experience.
Today we are going to discuss about one such new UI component: ‘SnackBars’ – You might have heard or seen in Apps at the bottom, which is introduced as a quick alternative for Toast.
In this post, following will be discussed:
- What is Toast?
- What is SnackBar?
- Difference between SnackBar and Toast.
- Usages of SnackBar and Toast
What is Snackbar?[box type=”download”]
Snackbar is an Android design component introduced as part of Material Design. It provide lightweight feedback about an operation by showing a brief message at the bottom of the screen. Snackbar can contain an action with which we can ask the App ro perform action like ‘Undo’ etc.,
Here is the quick snapshot of SnackBar being used in GMail App:
Reference: Android SnackBar
What is Toast?[box type=”bio”]
A toast is another Androdi design component that exists even before Material Design was started followed in Android. It provides simple feedback about an operation in a small popup that can appear at any part of the App (Mostly at the bottom of the App).
Snapshot of Toast goes here:
Difference between Toast and SnackBar
|1||Toast was added in API Level 1||SnackBar was added in API Level 23|
|2||Basically Activity is not required (Can be shown on Android home or even above other apps)||It can be showed inside an activity of the Applications|
|3||It can’t perform an action based on User input||It can perform an action|
|4||It can’t be dismissed by swiping||It can be dismissed by swiping|
|5||It can’t handle user input like Swipe, Click etc.,||It can handle user input|
|6||Good for showing info messages to user||Good for showing warning/info type messages to user that needs attention|
Usage of SnackBar and Toast
SnackBar can be used in the areas where a simple popup message needs to be displayed along with an option to perform action.
For Example: In GMail application, when you delete Mail, quick SnackBar display at the bottom with Message ‘1 Deleted’ with an action button ‘Undo’. On pressing the ‘Undo’ action button, the deleted mail will be restored.
Toast can be used in the areas where System messages need to be displayed.
When your App tries to download JSON from remote server but it fails due to Server Timeout or No resource found, you just need to display the error message saying that ‘Error Occurred’. But understand the Toast message cannot be dismissed by swiping. If you still want to have the capability of dismissing it in your App, go for SnackBar.
Hope you understand the difference between Toast and SnackBar. You can try your hands on creating simple Toast message and SnackBar by referring below links.