Android Snackbar Using Blueprint Back Upward Library

Posted on 32 views
With the unloose of Android Lollipop 5.0, Google also released novel pattern guidelines called fabric design. Google introduced many tools together with guidelines amongst fabric pattern together with also released pattern back upward library to piece of job fabric pattern tools for pre lollipop. With the help of this library, y’all tin move piece of job whatsoever fabric pattern tools for pre lollipop android device. In this article, I volition present y’all how to piece of job android snackbar using pattern back upward library.

Snackbar provided lightweight feedback to a user. Snackbar displays to a greater extent than or less message to a user together with tin move incorporate an action. This appears at the bottom of the covert together with inwards a higher house all others elements of the screen. They are inwards dissimilar size for mobile together with large screen. Snackbar automatically disappears later on a for sure time. This tin move incorporate icons, exactly using icon is non good. Snackbar tin move last used instead of toast. Here Google mentions when together with where to piece of job together with inwards this article, I’m going to present y’all how to implement snackbar to your android application using Android Design Support Library.

 Google also released novel pattern guidelines called fabric pattern Android Snackbar Using Design Support Library

How to Use Android Snackbar Using Design Support Library

It is non much hard to piece of job snackbar to your application.

Adding Dependency

First y’all convey to add together android pattern back upward library dependency to your android build.gradle file.

dependencies {     compile fileTree(dir: 'libs', include: ['*.jar'])     compile 'com.android.support:appcompat-v7:22.2.0'     compile 'com.android.support:design:22.2.0' }

Add CoordinatorLayout to Your Activity Layout

To piece of job snackbar to your android application, y’all convey to add together Coordinator Layout to your XML layout. After adding coordinator layout, your activity layout seems similar this.
res/layout/activity_main.xml

READ  How To Align Android Textview Inward The Midpoint Of The Screen

Modify Your Java Activity File

Modify code of your coffee file seems similar this.
src/MainActivity.java

Here snackBarView.setBackgroundColor allows y’all to alter background color of snackbar together with snackbar.setActionTextColor allows y’all to alter activeness text color.

Before running your application don’t forgot to add together colorPrimar together with colorPrimaryDark to your application theme. And your styses.xml file seems similar this.

<resources>     <!-- Base application theme. -->     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">         <!-- Customize your topic here. -->         <item name="colorPrimary">#ff21ab29</item>         <item name="colorPrimaryDark">#ff1e8622</item>     </style> </resources>

Now, run your android application, snackbar looks similar this.

 Google also released novel pattern guidelines called fabric pattern Android Snackbar Using Design Support Library
Android Snackbar Using Design Support Library