Choose a snackbar over a toast to make your users happy
Pro-tip by +Joanna Smith
Toasts are great for giving the user a simple message. But they don’t really do anything other than exist: they just appear on the screen, linger for a bit, and then fade away. Generally, this is fine, but if you’re using a toast to communicate with your users often, it can get annoying.
Instead, consider a Snackbar (http://goo.gl/nwRGer
). Snackbars also appear at the bottom of the screen and eventually fade away. But unlike a toast, a snackbar can be dismissed
with a swipe. This is pretty great when you want to inform the user that an action has completed, because they can read the message and then swipe it away when they’re done - giving users like me a chance to control exactly how long it remains on screen.
But snackbars aren’t just dismissable toasts. Snackbars can be enhanced to offer an action to the user.
Consider a photo deletion, where you were using a toast to say “Photo deleted!” and causing me to wait for 15 seconds before getting those pixels back. With a snackbar confirmation instead, you can still use the bottom of the screen to say “Photo deleted!” but you can also make me happy by letting me swipe it away. You can even prevent the “NO!” moment when I tried to tap “Share” and hit the trash can icon instead. Because you can add an “UNDO” action to that snackbar, offering me a chance to immediately correct my mistake instead of growling at your app (or interrupting me with a confirmation dialog every time). Now look at what a happy user I am!
To add an action to a snackbar, simply call setAction()
with your action string and a click event listener, and you’re all set.
It’s these minor adjustments that can fill your app with magic moments and anticipate your users’ needs. That is what makes the difference between an app users love and rate, and an app users uninstall and forget about. So check the design docs on snackbars and toasts to learn more about how and when to use each component. Then add the Android Design Support Library (http://goo.gl/Xf7Jp6
) to your project to start using Snackbars. And, of course, don’t forget to #BuildBetterApps