Although most of the toast notifications libraries are someway deprecated in favor of the new Design Support Library which includes a Toast. It is due to this that development of many libraries are no longer actively being maintained, however they work pretty nice (and there are other projects that are still being maintained)! If you are looking for a recommendation of which third party library you should use to implement custom toast notifications in Android, you are in the right place.
In this top, we'll share with you 7 of the most imponent libraries to build custom/default toasts notifications to display in your native android application.
7. 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. It has several method to display toasts based on the requirement. Each method returns a Toast object which can be customised further. 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.
DynamicToast.Config.getInstance()
// Background color for default toast.
.setDefaultBackgroundColor(@ColorInt int defaultBackgroundColor)
// Tint color for default toast.
.setDefaultTintColor(@ColorInt int defaultTintColor)
// Background color for error toast.
.setErrorBackgroundColor(@ColorInt int errorBackgroundColor)
// Background color for success toast.
.setSuccessBackgroundColor(@ColorInt int successBackgroundColor)
// Background color for warning toast.
.setWarningBackgroundColor(@ColorInt int warningBackgroundColor)
// Custom icon for error toast. Pass `null` to use default icon.
.setErrorIcon(@Nullable Drawable errorIcon)
// Custom icon for success toast. Pass `null` to use default icon.
.setSuccessIcon(@Nullable Drawable successIcon)
// Custom icon for warning toast. Pass `null` to use default icon.
.setWarningIcon(@Nullable Drawable warningIcon)
// Disable icon for all the toasts.
.setDisableIcon(boolean disableIcon)
// Custom icon size in `pixels` for all the toasts.
.setIconSize(int iconSize)
// Custom text size in `SP` for all the toasts.
.setTextSize(int textSize)
// Custom text typeface for all the toasts. Pass `null` to use system typeface.
.setTextTypeface(@Nullable Typeface textTypeface)
// Custom background drawable for all the toasts. Pass `null` to use default background.
.setToastBackground(@Nullable Drawable toastBackground)
// Apply customisations.
.apply();
6. Noty
A simple library for creating animated warnings/dialogs/alerts for Android.
5. SimpleToast
SimpleToast is a notification library for Android (like a Toast). The API is kept as simple as the Toast API. Create a SimpleToast for any CharSequence with default icon:
SimpleToast.ok(Context, CharSequence);
SimpleToast.error(Context, CharSequence);
SimpleToast.info(Context, CharSequence);
SimpleToast.muted(Context, CharSequence);
SimpleToast.warning(Context, CharSequence);
4. StyleableToast
StyleableToast is an Android library that takes the standard toast to the next level with many styling options. Style your toasts either by code or with a style in styles.xml
.
3. TastyToast
TastyToast is an useful library that implements custom Android toasts that look beautiful and not so boring as the native ones. After installing the library, you can use the toasts like this:
import com.sdsmdg.tastytoast.TastyToast;
// 1. Success message
TastyToast.makeText(
getApplicationContext(),
"Success message !",
TastyToast.LENGTH_LONG,
TastyToast.SUCCESS
);
// 2. Warning message
TastyToast.makeText(
getApplicationContext(),
"Warning message !",
TastyToast.LENGTH_LONG,
TastyToast.WARNING
);
// 3. Error message
TastyToast.makeText(
getApplicationContext(),
"Error message !",
TastyToast.LENGTH_LONG,
TastyToast.ERROR
);
// 4. Info message
TastyToast.makeText(
getApplicationContext(),
"Info message !",
TastyToast.LENGTH_LONG,
TastyToast.INFO
);
// 5. Default message
TastyToast.makeText(
getApplicationContext(),
"Default message !",
TastyToast.LENGTH_LONG,
TastyToast.DEFAULT
);
// 6. Confusion message
TastyToast.makeText(
getApplicationContext(),
"Confusion message !",
TastyToast.LENGTH_LONG,
TastyToast.CONFUSING
);
2. SuperToasts
The SuperToasts library enhances and builds upon the Android Toast class. This library includes support for context sensitive SuperActivityToasts that can show progress and handle button clicks as well as non-context sensitive SuperToasts which offer many customization options over the standard Android Toast class. You can create a super toast like this:
SuperActivityToast.create(getActivity(), new Style(), Style.TYPE_BUTTON)
.setButtonText("UNDO")
.setButtonIconResource(R.drawable.ic_undo)
.setOnButtonClickListener("good_tag_name", null, onButtonClickListener)
.setProgressBarColor(Color.WHITE)
.setText("Email deleted")
.setDuration(Style.DURATION_LONG)
.setFrame(Style.FRAME_LOLLIPOP)
.setColor(PaletteUtils.getSolidColor(PaletteUtils.MATERIAL_PURPLE))
.setAnimations(Style.ANIMATIONS_POP).show();
1. Toasty
Toasty is a simple android library that allows you to use the usual Toast, but with steroids. You can add this to your module's build.gradle
file (make sure the version matches the JitPack) and that's it. Each method always returns a Toast object, so you can customize the Toast much more. To display an error Toast:
Toasty.error(yourContext, "This is an error toast.", Toast.LENGTH_SHORT, true).show();
To display a success Toast:
Toasty.success(yourContext, "Success!", Toast.LENGTH_SHORT, true).show();
To display an info Toast:
Toasty.info(yourContext, "Here is some info for you.", Toast.LENGTH_SHORT, true).show();
To display a warning Toast:
Toasty.warning(yourContext, "Beware of the dog.", Toast.LENGTH_SHORT, true).show();
To display the usual Toast:
Toasty.normal(yourContext, "Normal toast w/o icon").show();
To display the usual Toast with icon:
Toasty.normal(yourContext, "Normal toast w/ icon", yourIconDrawable).show();
You can also create your custom Toasts with the custom() method:
Toasty.custom(yourContext, "I'm a custom Toast", yourIconDrawable, tintColor, duration, withIcon, shouldTint).show();
If you know another awesome open source library that allows you to implement toast like notifications in your android native application, please share it with the community in the comment box.