-
Notifications
You must be signed in to change notification settings - Fork 79
CreateAndShowSmartSnackBar
vincent(朱志强) edited this page Mar 20, 2022
·
2 revisions
- 创建一个显示在界面顶部的
snackbar,传入activity参数。
SmartSnackBar.top(this)- 创建一个显示在界面底部的
snackbar,传入activity参数。
SmartSnackBar.bottom(this)- 创建一个显示在界面底部的
snackbar,传入coordinator参数。snackbar会表现出在coordinator中的独有特性,如弹出时,FloatingActionButton会升高,手滑会消失等,适用于根布局为coordinator的情形。
SmartSnackBar.bottom(coordinatorLayout)//short
SmartSnackBar.bottom(this)
.show("one message")
//long
SmartSnackBar.bottom(this)
.showLong("one message")
//indefinite
SmartSnackBar.bottom(this)
.showIndefinite("one message")- 只指定message和actionLabel,点击actionLabel后snackbar消失
//short
SmartSnackBar.bottom(this)
.show("one message with action","confirm")
//long
SmartSnackBar.bottom(this)
.showLong("one message with action","confirm")
//indefinite
SmartSnackBar.bottom(this)
.showIndefinite("one message with action","confirm")- 指定message、actionLabel、actionListener
//short
SmartSnackBar.bottom(this)
.show("one message with action", "confirm") {
//do something
}
//long
SmartSnackBar.bottom(this)
.showLong("one message with action", "confirm") {
//do something
}
//indefinite
SmartSnackBar.bottom(this)
.showIndefinite("one message with action", "confirm") {
//do something
}- 隐藏当前显示的snackbar
SmartSnackBar.dismiss()- 只隐藏当前显示在顶部的snackbar
SmartSnackBar.dismissTop()- 只隐藏当前显示在底部的snackbar
SmartSnackBar.dismissBottom()1