Source link: https://github.com/ZahraHeydari/Toastest
How to customize Toast? Here an example how to make it happen. Whit this library you can make Toast with background, toast with custom font or setup the text size.
Thank you for developer. This lib will help much.
Toastest
This is for customizing toasts!
Prerequisites
Add this in your root build.gradle
file (not your module build.gradle
file):
allprojects {
repositories {
... maven {
url "https://jitpack.io"
}
}
}
Dependency
Add this to your module s build.gradle
file (make sure the version matches the JitPack badge above):
dependencies {
... implementation com.github.ZahraHeydari:Toastest:1.0.0
}
Usage
Each method always returns a Toast
object, so you can customize the Toast with below methods.
This displays a Toast with an icon.
Toastest.makeToast(context, "This is a toast with an icon.", iconDrawable,Toast.LENGTH_SHORT).show()
This displays a Toast with a new background.
Toastest.makeToast(context, background, "This a toast with a background.", Toast.LENGTH_SHORT).show()
This displays a Toast with a new font type.
Toastest.makeToast(context, "This a toast with a new font type.", TEXT_TYPEFACE, Toast.LENGTH_SHORT).show()
This displays a Toast with a new text size.
Toastest.makeToast(context, "This a toast with a new text size.", TEXT_SIZE, Toast.LENGTH_SHORT).show()
And you can create your custom Toasts with the custom()
method:
Toastest.custom(context, "This is a fully customized toast.", iconDrawable, backgroundDrawable, TEXT_SIZE, TEXT_TYPEFACE, Toast.LENGTH_SHORT).show()
Author
- ZARA