<font class="popmake-631">Subscribe</font>Subscribe with Androidlift to get new post on mail.

Android Material Design Snackbar Example

Android Material  Design snackbar Example


This post explains Android Material Design snackbar Example of different snackbar styles.

Snackbars provide lightweight feedback about an operation by showing a brief message at the bottom of the screen. Snackbars can contain an action.

Android also provides a toast, primarily used for system messaging. Toasts are similar to snackbars but do not contain actions and cannot be swiped off screen.


Show only one snackbar on screen at a time.


Snackbars appear above most elements on screen, and they are equal in elevation to the floating action button. However, they are lower in elevation than dialogs, bottom sheets, and navigation drawers.


Upon entrance, snackbars animate upwards from the bottom edge of the screen. When they appear, they do not block input.

They exit by being swiped off-screen or automatically disappear after a timeout or user interaction elsewhere (such as summoning a new surface or activity).


Lets create project in android studio and follow the coding.

In this application we have 3 buttons as follows-

  • Simple Snackbar

simple snackbar
simple snackbar

Check below syntax for a simple snackbar.

– make(View view, CharSequence text, int duration)  –  Make a Snackbar to display a message

And duration should be

  • LENGTH_SHORT – Show the Snackbar indefinitely.
  •  LENGTH_LONG –  Show the Snackbar for a long period of time.
  • LENGTH_INDEFINITE –  Show the Snackbar indefinitely.
  • Snackbar with Action Buttons
actioncallback snackbar
actioncallback snackbar

– public Snackbar setAction (CharSequence text, View.OnClickListener listener)

Set the action to be displayed in this Snackbar.


text Text to display
listener callback to be invoked when the action is clicked

  • Custom Snackbar 
Android Material Design snackbar Example
Android Material Design snackbar Example

And this is the customized snackbar with backround color and textcolor along with aciton call back.


The complete coding is below..








We are done here..Now run and check the app..

Have good day…!