Awesome
SnackBar; toast-like alert pattern for Android inspired by the Google Material Design Spec
Deprecated
This library is deprecated in favor of the new Design Support Library which includes a Snackbar. It is due to this development that this library is no longer activly being developed.
Features
- 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
New Features since 1.0.0
- Set custom background color
- Set custom height
- Set custom typeface
Usage
-
Add SnackBar to your project ###Maven Just add the following to your
build.gradle
.dependencies { compile 'com.github.mrengineer13:snackbar:1.2.0' }
-
Show a message
Build SnackBar in Activity
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();
Build SnackBar in Fragment
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();
Using this library?
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 |
---|---|
<img src="https://lh4.ggpht.com/uADrrF0FMReNrt7ap_cI-057Zmsl6awZWhpjA0Eupe-HGou1-FFb1ECeta3ED4N1Mos=w300-rw" width="48" height="48" /> | Plume |
<img src="https://lh6.ggpht.com/pTT1RebLeNJMH7pm9XgQtDWpm0azxOJ7dFYkZqAMT-QE1oi2OGor3qI1ZgiJze4uYvo=w300-rw" width="48" height="48" /> | Score It |
<img src="https://lh5.ggpht.com/_r-p6eZOnWIPpu5B-jNHWeHBhT-2UC_OZxRFE-BapvdJLIBA2qrrSrOLm15SZsAC1X0=w300-rw" width="48" height="48" /> | LoterĂa Navidad 2014 |
<img src="https://lh3.ggpht.com/Mz6YqxKsLfVbjYVHj_3nfUxLe5Yvl9W4KO2sKnwud6hZl5mnGitm55PnILT2jx4Hafv6=w300-rw" width="48" height="48" /> | Journal |
<img src="https://lh4.ggpht.com/DvzthG-_lJsR7Ny8in8KPtEuNAgzzJSdlvUg2EG8qvXH0Oq5YJFQffWjFNKblx2GVAA=w300" width="48" height="48" /> | My Garage |
<img src="https://lh6.ggpht.com/hdfIOAe9xYS3NzgTx1_3IfVwCP8UCyxDpXHxbviVMPg3iCEkrZudFZ4iuYQNvOp-aKI=w300" width="48" height="48" /> | QuoteMe |
Contribution
Pull requests are welcome!
Feel free to contribute to SnackBar.
Just create your branch then submit 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.