项目作者: TooLazyy

项目描述 :
Android library to provide TOP (or BOTTOM) toast functionality. Write in Kotlin.
高级语言: Kotlin
项目地址: git://github.com/TooLazyy/AndroidTopToast.git
创建时间: 2018-04-18T21:39:24Z
项目社区:https://github.com/TooLazyy/AndroidTopToast

开源协议:

下载


AndroidTopToast

Library allows to show top toast (like Snackbar view).

Screenshots


Simple toast Custom colors Bottom gravity
Above status bar Custom view Custom layoutId

Usage


Use Kotlin DSL to create TopToast instance:

  1. val topToast {
  2. removeOnSwipe = TopToast.TOASTSWIPE.TOP
  3. context = this@MainActivity
  4. showAboveStatusBar = false
  5. }

To show toast use topToast.showTopToas(), to remove - toast.removeTopToast()

Full parameters:

  1. val toast = topToast {
  2. toastGravity = TopToast.TOASTGRAVITY.BOTTOM
  3. removeOnSwipe = TopToast.TOASTSWIPE.TOP
  4. context = this@MainActivity
  5. showAboveStatusBar = true
  6. viewSettings {
  7. duration = 3000L
  8. type = TOAST_TYPE.DEFAULT
  9. //gonna be ignored
  10. textColor = Color.RED
  11. //gonna be ignored
  12. backgroundColor = Color.BLACK
  13. //gonna be ignored
  14. textToShow = "text"
  15. //gonna be ignored
  16. layoutId = R.layout.my_awesome_toast
  17. //gonna be used (max priority)
  18. customView = custom
  19. }
  20. }

Params

  1. duration - duration of toast before autoremove, set to TopToast.NO_AUTO_REMOVE to disable autoremove
  2. toastGravity - gravity on screen (TopToast.TOASTGRAVITY.TOP or TopToast.TOASTGRAVITY.BOTTOM)
  3. context - activity context
  4. showAboveStatusBar - should toast cover status bar or not (for 6+ devices toast DOES NOT cover status bar icons)
  5. 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)
  6. viewSettings - toast view settings
    6.1 textColor - default text color (WHITE)
    6.2 backgroundColor - default bg color (RED)
    6.3 textToShow - text to show
    6.4 layoutId - layout resource id.
    6.5 customView - custom View.

Changes

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).