Home / UI / Material Design / Android Material Design Snackbar
featured_image

Android Material Design Snackbar

Google announced Material Design Support Library in their Google IO 2015. One of the interesting components is the Android Material Design Snackbar. In this tutorial we’ll have a look on Android Material Design Snackbar types and functions.

You can check our Android Material Design Series from here. 

Snackbar is just like Toast messages but it has some advantage functions as they provide action to interact with. Android Material Design Snackbar will be displayed at the bottom of the screen and can be swiped off in order to dismiss them.

 

Quick Overview:

There are three main scenarios for the Android Material Design Snackbar

1. Simple Snackbar

Android Material Design Snackbar

2. Snackbar with Action

Android Material Design Snackbar

3. Customized Snackbar

Android Material Design Snackbar

Android Material Design Snackbar

1. Creating Android Project, In Android Studio, create a new project by navigating to File ⇒ New Project and fill all the required details. When it prompts to select a default activity, select Blank Activity and proceed.

2. We need to add Material Design Support Library so we can use it, so open build.gradle file and add the following code:

3. Let’s add some styles, Open colors.xml under res ⇒ values and add below color resources. If you don’t find colors.xml, create a new file with the name.

Also Open styles.xml under res ⇒ values and add below color resources, that will customize the app so it will look like the screenshot above.

4. Open the layout file the main activity activity_main.xml and add below code. This includes 3 Buttons and the parent layout is CoordinatorLayout, WHY ?! CoordinatorLayout as view param is the best option as it allows Snackbar to enable some features like swipe-to-dismiss and automatically moving of widgets like FloatingActionButton.

5. Finally Add this code to your Main Activity java file MainActivity.java. This code has 3 methods, one for each button on our layout and it represents the three types of the Android material design snackbar.

6. Run the project and test it. You should able see The Android Material Design Snackbar. Design Support Library and it will look like this:

Android Material Design Snackbar

Summary
Article Title
Android Material Design Snackbar Tutorial
Description
Android Material Design Snackbar with Design Support Library is like Toast messages but it has some advantage functions like provide action to interact with
Author
Organization
Android Gifts

About #AndroidGifts

#AndroidGifts

Check Also

featured_image

Material Design Icons with Android Studio Plugin Drawable Importer – Library #1

In this tutorial we are having Material Design Icons with Android Studio Drawable Importer Plugin which …