π I built a Modern Android Toast Library that works properly on Android 11+ (with icons, colors & Version Catalog support)
Androidβs default Toast customization stopped working reliably after Android 11 (API 30).
Setting background colors directly on Toast views is now restricted β which makes many old solutions break.
So I built a lightweight modern alternative:
π Toast Library
It provides:
β
Success / Error / Info / Default variants
π¨ Colored rounded backgrounds
π§© Built-in vector icons
π Gravity control (TOP / CENTER / BOTTOM)
π¦ JitPack installation
π§° Version Catalog support (latest Android Studio)
β‘ Lightweight & dependency-free
π¦ Installation (JitPack)
Step 1 β Add JitPack repository
Inside settings.gradle.kts
pluginManagement {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}
β Recommended: Version Catalog setup (Latest Android Studio)
Inside:
gradle/libs.versions.toml
Add:
[versions]
toastlib = "v2.0.0"
[libraries]
toastlib = { module = "com.github.TutorialsAndroid:Toast-Library", version.ref = "toastlib" }
Then inside:
app/build.gradle.kts
dependencies {
implementation(libs.toastlib)
}
Alternative: Direct dependency
dependencies {
implementation("com.github.TutorialsAndroid:Toast-Library:v2.0.0")
}
π Usage Examples
Success Toast
ToastLib.success(this, "Saved successfully");
Error Toast
ToastLib.error(this, "Something went wrong");
Info Toast
ToastLib.info(this, "Welcome back!");
Default Toast
ToastLib.show(this, "Default toast");
π Custom Position Example
ToastLib.show(
this,
"Top message",
ToastLib.ToastType.INFO,
Gravity.TOP
);
π± Why this library exists
Older approaches:
toast.getView().setBackgroundColor(...)
no longer work consistently on modern Android versions.
This library solves that using:
β custom layouts
β vector icons
β Material-style backgrounds
β Android 11+ compatibility
π¦ GitHub Repo
β Check it out here:
https://github.com/TutorialsAndroid/Toast-Library
Feedback and contributions welcome!
π£ Roadmap
Next updates coming soon:
β¨ toast animations
β¨ builder pattern API
β¨ dark mode support
β¨ custom icon support
If this helps your Android projects, consider giving the repo a β
Top comments (0)