Android library to provide TOP (or BOTTOM) toast functionality. Write in Kotlin.
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 to TopToast.NO_AUTO_REMOVE
to disable autoremovetoastGravity
- gravity on screen (TopToast.TOASTGRAVITY.TOP
or TopToast.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. If TopToast.TOASTSWIPE.NONE
(default value) selected - swipe not working, if TopToast.TOASTSWIPE.ANY
selected - swipe detect any direction (left, top, bottom, right)viewSettings
- toast view settingstextColor
- default text color (WHITE
)backgroundColor
- default bg color (RED
)textToShow
- text to showlayoutId
- layout resource id.customView
- custom View
.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
).