A lightweight helper class for Android developers to show colored Toasts with icons in one line of code.
- 🎨 Custom background colors
- 🖼️ Add icons easily
- ⚡ Plug-and-play, no dependencies
- 📱 Works with all Android versions
CustomToast.show(this, "Success!", Color.GREEN, R.drawable.ic_check);
CustomToast.show(this, "Error!", Color.RED, R.drawable.ic_error);
CustomToast.show(this, "Warning!", Color.YELLOW, R.drawable.ic_warning);
// Success Toast
CustomToast.success(this, "Operation Successful!");
// Error Toast
CustomToast.error(this, "Something went wrong!");
// Warning Toast
CustomToast.warning(this, "Please be careful!");
// Info Toast
CustomToast.info(this, "Here's some information!");
- Copy
CustomToast.javainto your project undercom/ousaf/customtoast/ - Add your icons to
res/drawable/ - Define colors in
res/values/colors.xml - Import and use in your Activities
Button btn = findViewById(R.id.button);
btn.setOnClickListener(v -> {
CustomToast.show(this, "Login Successful!", Color.GREEN, R.drawable.ic_check);
});
You can easily customize:
- Colors: Use any Android Color or resource
- Icons: Any drawable resource
- Duration: Modify toast duration in the utility
- Text Size: Adjust font size as needed
MIT License – free to use, modify, and share.
Made with ❤️ by Ousaf | Contributions welcome!