Dynamic Toasts
A simple library to display themed toasts with icon and text on Android 9+ (Gingerbread or above) devices.
Since v0.4.0, it uses 26.x.x support libraries so, minimum SDK will be Android 14+ (ICS or above).
Since v2.0.0, it uses AndroidX so, first migrate your project to AndroidX.
Installation
It can be installed by adding the following dependency to your build.gradle
file:
Usage
It has several method to display toasts based on the requirement. Each method returns a Toast
object which can be customised further.
Please call show()
method to display the toast.
For complete reference, please read the documentation.
Configuration
Optional configuration to customise the toasts further like custom background color or drawable,
custom text size, typeface or icon size, etc.
Various methods can be called anywhere in the app to do customisations.
Call reset()
method to reset all the customisations.
Default toast
Simple toast based on the vanilla Android theme for Toast.LENGTH_SHORT
duration.
Default toast with duration
Simple toast based on the vanilla Android theme for supplied duration.
Default toast with icon
Simple toast based on the vanilla Android theme with a icon for Toast.LENGTH_SHORT
duration.
Default toast with icon and duration
Simple toast based on the vanilla Android theme with a icon for supplied duration.
Error toast
Error toast with #F44336
background for Toast.LENGTH_SHORT
duration.
Error toast with duration
Error toast with #F44336
background for supplied duration.
Success toast
Success toast with #4CAF50
background for Toast.LENGTH_SHORT
duration.
Success toast with duration
Success toast with #4CAF50
background for supplied duration.
Warning toast
Warning toast with #FFEB3B
background for Toast.LENGTH_SHORT
duration.
Warning toast with duration
Warning toast with #FFEB3B
background for supplied duration.
Custom toast
Custom toast based on the supplied background and tint color for Toast.LENGTH_SHORT
duration.
Custom toast with duration
Custom toast based on the supplied background and tint color for supplied duration.
Custom toast with icon
Custom toast based on the supplied icon, background and tint color theme for Toast.LENGTH_SHORT
duration.
Custom toast with icon and duration
Custom toast based on the supplied icon, background and tint color theme for supplied duration.
Cheat sheets
Use dynamic hint to display cheat sheets for any view
. All the methods are same as explained
above, just replace DynamicToast
with DynamicHint
to create a cheat sheet.
Use
DynamicHint.show(view, toast)
method to display it according to the anchor view position.
Dependency
It depends on the dynamic-utils to perform
various internal operations. So, its functions can also be used to perform other useful operations.