Android SnackBar is a popup message showed from the bottom of the screen. Which will be disappeared after a timeout or you can swipe to cancel. This snack bar appears on top of all other elements on the screen just like Toasts. You can customize it like changing text color, creating actions or even change the action button color.
Snackbar can contain actions and that is the major difference between toast and SnackBar. snack bar is introduced in the android material design library.
Here is a simple code for showing Android SnackBar.
Here the parent layout refers to the topmost layout element which usually will be constraint layout. Just call this code inside onCreate() method and SnackBar will be shown
Implementing click action
call this method in snack bar object to change the action button color
changing message color
Now you have successfully created a snack bar in android and customized to your needs. If you found this tutorial useful to you or If you want me to cover a topic that’s hard for you, please let me know in the comments below.
Also, do check out my most popular android tutorial here