Using SnackBar - Material Design :
To display a post action notification we used Toasts, but the introduction to material design came SnackBar. To use SnackBar :
In your gradle file(app), within your dependencies add :
dependencies {
...
compile 'com.android.support:design:22.2.0'
In your java file, where you want to show notification :
**You’ll note the use of a
parentLayout example :
ScreenShot :
Complete Source Code : SnackBarDemo
For any doubts you can comment below, i'll respond ASAP.
To display a post action notification we used Toasts, but the introduction to material design came SnackBar. To use SnackBar :
In your gradle file(app), within your dependencies add :
dependencies {
...
compile 'com.android.support:design:22.2.0'
}
In your java file, where you want to show notification :
Snackbar
.make(parentLayout,"This is a SnackBar!",Snackbar.LENGTH_LONG) .setAction("Action", null) .show();
**You’ll note the use of a
View
as the first parameter to make() - Snackbar
will attempt to find an appropriate parent of the Snackbar
’s view to ensure that it is anchored to the bottom.parentLayout example :
public void snackBar(View view) { Snackbar.make(view, "This is SnackBar!"Snackbar.LENGTH_LONG) .setAction("Action", null)
.show(); }
ScreenShot :
Complete Source Code : SnackBarDemo
For any doubts you can comment below, i'll respond ASAP.