Library allows to show top toast (like Snackbar view).
Simple toast | Custom colors | Bottom gravity |
---|---|---|
Above status bar | Custom view | Custom layoutId |
---|---|---|
Use Kotlin DSL
to create TopToast
instance:
val topToast {
removeOnSwipe = TopToast.TOASTSWIPE.TOP
context = this@MainActivity
showAboveStatusBar = false
}
To show toast use topToast.showTopToas()
, to remove - toast.removeTopToast()
Full parameters:
val toast = topToast {
toastGravity = TopToast.TOASTGRAVITY.BOTTOM
removeOnSwipe = TopToast.TOASTSWIPE.TOP
context = this@MainActivity
showAboveStatusBar = true
viewSettings {
duration = 3000L
type = TOAST_TYPE.DEFAULT
//gonna be ignored
textColor = Color.RED
//gonna be ignored
backgroundColor = Color.BLACK
//gonna be ignored
textToShow = "text"
//gonna be ignored
layoutId = R.layout.my_awesome_toast
//gonna be used (max priority)
customView = custom
}
}
duration
- duration of toast before autoremove, set toTopToast.NO_AUTO_REMOVE
to disable autoremovetoastGravity
- gravity on screen (TopToast.TOASTGRAVITY.TOP
orTopToast.TOASTGRAVITY.BOTTOM
)context
- activity contextshowAboveStatusBar
- should toast cover status bar or not (for 6+ devices toast DOES NOT cover status bar icons)removeOnSwipe
- swipe direction to remove toast from screen.LEFT, TOP, BOTTOM, RIGHT
are supported. IfTopToast.TOASTSWIPE.NONE
(default value) selected - swipe not working, ifTopToast.TOASTSWIPE.ANY
selected - swipe detect any direction (left, top, bottom, right)viewSettings
- toast view settings 6.1textColor
- default text color (WHITE
) 6.2backgroundColor
- default bg color (RED
) 6.3textToShow
- text to show 6.4layoutId
- layout resource id. 6.5customView
- customView
.
Now viewSettings
contains parameter type
of type TOAS_TYPE
.
Possible values - DEFAULT
, CUSTOM_VIEW
, CUSTOM_VIEW_ID
.
If DEFAULT
is set - layoutId
and customView
gonna be IGNORED.
If layoutId
or customView
are set, specify a appropriate type
(default value is DEFAULT
).