ToastLib is a lightweight Android library that provides customizable, modern toast messages with icons, colors, gravity control, and clean API usage. It works reliably on Android 11+ using custom layouts instead of deprecated system toast styling.
If you find ToastLib useful, please consider supporting the project:
⭐ Star this repository
🐛 Report issues
💡 Suggest new features
And don’t forget to follow me on Instagram for more developer content:
📸 https://instagram.com/coderx09
Thanks for your support! 🚀
- ✅ Success / Error / Info / Default toast variants
- 🎨 Colored rounded backgrounds
- 🧩 Built-in vector icons
- 📍 Custom toast gravity support (TOP / CENTER / BOTTOM)
- 📱 Android 11+ compatible
- 🧼 Clean static API
- ⚡ Lightweight & dependency-free
pluginManagement {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}[versions]
toastlib = "v2.0.0"
[libraries]
toastlib = { module = "com.github.TutorialsAndroid:toastlibrary", version.ref = "toastlib" }Then inside module build.gradle.kts
dependencies {
implementation(libs.toastlib)
}Add inside app/build.gradle.kts
dependencies {
implementation("com.github.TutorialsAndroid:toastlibrary:v2.0.0")
}Import the library
import com.app.toastlibrary.ToastLib;ToastLib.success(this, "Saved successfully");ToastLib.error(this, "Something went wrong");ToastLib.info(this, "Welcome back!");ToastLib.show(this, "Default toast");ToastLib.show(
this,
"Top message",
ToastLib.ToastType.INFO,
Gravity.TOP
);| Type | Method |
|---|---|
| Success | ToastLib.success() |
| Error | ToastLib.error() |
| Info | ToastLib.info() |
| Default | ToastLib.show() |
| Android Version | Supported |
|---|---|
| Android 7+ | ✅ |
| Android 11+ | ✅ Fully compatible |
| Android 15+ | ✅ Tested |
Project
├── app
├── toastlibrary
└── gradle
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ToastLib.success(this, "Saved successfully");
}
}Android default Toast customization stopped working reliably after Android 11.
ToastLib solves this by:
- Using custom layouts
- Supporting vector icons
- Providing background variants
- Maintaining backward compatibility
Upcoming features:
- ⏳ Toast animations
- 🎯 Builder pattern API
- 🌙 Dark mode auto adaptation
- 🎭 Custom icon support API
Pull requests are welcome!
If you'd like to improve ToastLib:
- Fork repository
- Create feature branch
- Commit changes
- Submit PR
MIT License
If this library helped you, consider giving it a star ⭐ on GitHub.