SnackBar; toast-like alert pattern for Android inspired by the Google Material Design Spec
- Set message text and optionally duration
- Shows only one message at a time
- Can have action item (e.g. undo, refresh, etc.)
- Set text color of action items
- Swipe down to dismiss all notifications as per documentation
- Backwards compatible to 2.3.x
- Set custom background color
- Set custom height
- Set custom typeface
##1. Add SnackBar to your project
###Maven
Just add the following to your build.gradle
.
dependencies {
compile 'com.github.mrengineer13:snackbar:1.2.0'
}
new SnackBar.Builder(this)
.withOnClickListener(this)
.withMessage("This library is awesome!") // OR
.withMessageId(messageId)
.withTypeFace(myAwesomeTypeFace)
.withActionMessage("Action") // OR
.withActionMessageId(actionMsgId)
.withTextColorId(textColorId)
.withBackGroundColorId(bgColorId)
.withVisibilityChangeListener(this)
.withStyle(style)
.withDuration(duration)
.show();
new SnackBar.Builder(getActivity().getApplicationContext(), root)
.withOnClickListener(this)
.withMessage("This library is awesome!") // OR
.withMessageId(messageId)
.withTypeFace(myAwesomeTypeFace)
.withActionMessage("Action") // OR
.withActionMessageId(actionMsgId)
.withTextColorId(textColorId)
.withBackGroundColorId(bgColorId)
.withVisibilityChangeListener(this)
.withStyle(style)
.withDuration(duration)
.show();
If you're using this library in one of your projects just send me a tweet and I'll add your project to the list.
Icon | Application |
---|---|
Plume | |
Score It | |
LoterĂa Navidad 2014 | |
Journal | |
My Garage | |
QuoteMe |
Feel free to contribute to SnackBar.
If you've implemented a bug fix or new feature, just create a pull request on the dev branch.
If you have a bug to report a feature to request or have other questions, file an issue. I'll try to answer as soon as I can.