Curation of some of the best android Toast libraries this year.

Contents hide

1. Spikeysanju/MotionToast

🌈 A Beautiful Motion Toast Library for Kotlin Android.

Toast Library Tutorial

A Beautiful Multipurpose Motion Toast Library in Android using Kotlin.

MotionToast Example Tutorial

Preview - Motion Toast 🌟

MotionToast Example Tutorial

Preview - Color Motion Toast 🌈

MotionToast Example Tutorial

Preview - Dark Toast 🌈

MotionToast Example Tutorial

Preview - Dark Color Toast 🌈

MotionToast Example Tutorial

Types of Toast Style ❤️

MotionToast Example Tutorial

MotionToast Example Tutorial

MotionToast Example Tutorial

MotionToast Example Tutorial

Step 1: Installation

Dependency Project Level

Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Dependency App Level:

Add dependency in your app module

dependencies {
            implementation 'com.github.Spikeysanju:MotionToast:1.4' 
    }

Step 2: Usage

Five Toast Types

1. TOAST_SUCCESS
        2. TOAST_ERROR
        3. TOAST_WARNING
        4. TOAST_INFO
        5. TOAST_DELETE

Toast Duration ⌛️

1. LONG_DURATION // 4 Seconds
        2. SHORT_DURATION // 2 Seconds

Success Toast

MotionToast.createToast(this,
        "Hurray success 😍"
        "Upload Completed successfully!",
                MotionToastStyle.SUCCESS,
                MotionToast.GRAVITY_BOTTOM,
                MotionToast.LONG_DURATION,
                ResourcesCompat.getFont(this,R.font.helvetica_regular))

Error Toast

MotionToast.createToast(this,
            "Failed ☹️"
            "Profile Update Failed!",
                    MotionToastStyle.ERROR,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Warning Toast

MotionToast.createToast(this,"Please fill all the details!",
                    MotionToastStyle.WARNING,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Info Toast

MotionToast.createToast(this,"This is information toast!",
                    MotionToastStyle.INFO,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Delete Toast

MotionToast.createToast(this,"Delete all history!",
                    MotionToastStyle.DELETE,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Sample Code for - Color Motion Toast 🌈

Success Toast

MotionToast.createColorToast(this,"Upload Completed!",
                MotionToastStyle.SUCCESS,
                MotionToast.GRAVITY_BOTTOM,
                MotionToast.LONG_DURATION,
                ResourcesCompat.getFont(this,R.font.helvetica_regular))

Error Toast

MotionToast.createColorToast(this,"Profile Update Failed!",
                    MotionToastStyle.ERROR,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Warning Toast

MotionToast.createColorToast(this,"Please fill all the details!",
                    MotionToastStyle.WARNING,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Info Toast

MotionToast.createColorToast(this,"This is information toast!",
                    MotionToastStyle.INFO,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Delete Toast

MotionToast.createColorToast(this,"Delete all history!",
                    MotionToastStyle.DELETE,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Success Toast

MotionToast.darkToast(this,"Upload Completed!",
                MotionToastStyle.SUCCESS,
                MotionToast.GRAVITY_BOTTOM,
                MotionToast.LONG_DURATION,
                ResourcesCompat.getFont(this,R.font.helvetica_regular))

Error Toast

MotionToast.darkToast(this,"Profile Update Failed!",
                    MotionToastStyle.ERROR,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Warning Toast

MotionToast.darkToast(this,"Please fill all the details!",
                    MotionToastStyle.WARNING,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Info Toast

MotionToast.darkToast(this,"This is information toast!",
                    MotionToastStyle.INFO,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Delete Toast

MotionToast.darkToast(this,"Delete all history!",
                    MotionToastStyle.DELETE,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Sample Code for - Dark Color Toast 🌚🖤🌈

Success Toast

MotionToast.darkColorToast(this,"Upload Completed!",
                MotionToastStyle.SUCCESS,
                MotionToast.GRAVITY_BOTTOM,
                MotionToast.LONG_DURATION,
                ResourcesCompat.getFont(this,R.font.helvetica_regular))

Error Toast

MotionToast.darkColorToast(this,"Profile Update Failed!",
                    MotionToastStyle.ERROR,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Warning Toast

MotionToast.darkColorToast(this,"Please fill all the details!",
                    MotionToastStyle.WARNING,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Info Toast

MotionToast.darkColorToast(this,"This is information toast!",
                    MotionToastStyle.INFO,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Delete Toast

MotionToast.darkColorToast(this,"Delete all history!",
                    MotionToastStyle.DELETE,
                    MotionToast.GRAVITY_BOTTOM,
                    MotionToast.LONG_DURATION,
                    ResourcesCompat.getFont(this,R.font.helvetica_regular))

Full Example

For a full MotionToast Toast Library example project follow the following steps.

Read more Read More.


2. TastyToasty

An easy-to-use library to create tasty 😋 Toasts with a bunch of flavours.

It also provides effortless methods to create Instagram like Toasts.

Toast Library Tutorial

Toast Library Tutorial

Step 1: Installation

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Add this to your module's build.gradle file :

dependencies {
    ...
    implementation 'com.github.usman18:TastyToasty:v1.2'
}

Step 2: Usage

Instagram Toasts

TastyToasty Example Tutorial

TastyToasty.instaLike(MainActivity.this, "1").show();
  1. instaFollower:

TastyToasty Example Tutorial

  1. instaComment:

TastyToasty Example Tutorial

TastyToasty Example Tutorial

TastyToasty.instaAll(MainActivity.this, "101","20","60").show();

VIBGYOR Toasts 🌈

TastyToasty Example Tutorial

TastyToasty.violet(MainActivity.this, "Its lit", R.drawable.ic_whatshot).show();

TastyToasty Example Tutorial

TastyToasty Example Tutorial

TastyToasty Example Tutorial

TastyToasty Example Tutorial

TastyToasty Example Tutorial

TastyToasty Example Tutorial

Standard Toasts

TastyToasty Example Tutorial

TastyToasty.success(MainActivity.this, "Task Successful").show();

TastyToasty Example Tutorial

TastyToasty Example Tutorial

TastyToasty Example Tutorial

Custom Toasts

TastyToasty Example Tutorial

// Pass the last attribute as false or null if your do not want the tail in Toast
TastyToasty.makeText(MainActivity.this, "This is a custom toast",TastyToasty.LONG, R.drawable.ic_action_favourite, R.color.violet, R.color.white, true).show();

TastyToasty Example Tutorial

new TastyToasty.Builder(MainActivity.this)
  .setText("This one is using builder method")    
  .setBackgroundColor(R.color.green)      
  .setIconId(R.drawable.ic_verified_user)
  .showTail(true) // Pass false or null or don't call at all if you don't want the "tail" in your toast
  .show();

Note:

//Default text color is white and default background color is pinkinsh red
new TastyToasty.Builder(MainActivity.this)
    .setIconId(R.drawable.ic_whatshot)
    .show();

TastyToasty Example Tutorial

Full Example

Let us look at a full android Toast Library sample project.

Read more Read More.


3. FancyToast-Android

Make your native android Toasts Fancy.

A library that takes the standard Android toast to the next level with a variety of styling options. Style your toast from code..

Toast Library Tutorial

Step 1: Declare Repository

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
    repositories {
        ...
        mavenCentral()
    }
}

Step 2: Add Dependency

This library is available on MavenCentreal
Add this to your module's build.gradle file (make sure the version matches the Maven-Central badge above):

dependencies {
    ...
    implementation 'io.github.shashank02051997:FancyToast:2.0.2'
}

Step 3: Usage

Each method always returns a Toast object, so you can customize the Toast much more. DON'T FORGET THE show() METHOD!
show()
To display an default Toast:

FancyToast.makeText(this,"Hello World !",FancyToast.LENGTH_LONG,FancyToast.DEFAULT,true);

To display a success Toast:

FancyToast.makeText(this,"Hello World !",FancyToast.LENGTH_LONG,FancyToast.SUCCESS,true);

To display an info Toast:

FancyToast.makeText(this,"Hello World !",FancyToast.LENGTH_LONG,FancyToast.INFO,true);

To display a warning Toast:

FancyToast.makeText(this,"Hello World !",FancyToast.LENGTH_LONG,FancyToast.WARNING,true);

To display the error Toast:

FancyToast.makeText(this,"Hello World !",FancyToast.LENGTH_LONG,FancyToast.ERROR,true);

To display the confusing Toast:

FancyToast.makeText(this,"Hello World !",FancyToast.LENGTH_LONG,FancyToast.CONFUSING,true);

You can also remove the android icon on top-right corner by passing last parameter false.

FancyToast.makeText(yourContext, "I'm a Toast", duration, type, boolean value).show();

You can also create your custom Toasts with passing your image with or without android icon(top-right corner):

FancyToast.makeText(yourContext, "I'm a custom Toast", duration, type, yourimage, boolean value).show();

To display the custom Toast with no android icon:

FancyToast.makeText(this, "This is Custom Toast with no android icon", FancyToast.LENGTH_LONG, FancyToast.CONFUSING, R.drawable.ic_android_black_24dp, false);

Screenshots

Please click the image below to enlarge.
FancyToast-Android Example Tutorial

Full Example

Let us look at a full Fancy Toast Library Example below.

Read more Read More.


4. pranavpandey/dynamic-toasts

Custom toasts with color and icon on Android..

Dynamic Toasts

Toast Library Tutorial

Toast Library Tutorial

A simple library to display themed toasts with icon and text on Android 2.3 (API 9) and above.

Toast Library Tutorial

Installation

It can be installed by adding the following dependency to your build.gradle file:

dependencies {
    // For AndroidX enabled projects.
    implementation 'com.pranavpandey.android:dynamic-toasts:4.1.2'

    // For legacy projects.
    implementation 'com.pranavpandey.android:dynamic-toasts:1.3.0'
}

Usage

Just call show() method to display the toast.

Configuration

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();

Call reset() method to reset all the customisations.

// Reset customisations.
DynamicToast.Config.getInstance().reset();

Default toast

Simple toast based on the vanilla Android theme for Toast.LENGTH_SHORT duration.

DynamicToast.make(context, "Default toast").show();

Default toast with duration

Simple toast based on the vanilla Android theme for supplied duration.

DynamicToast.make(context, "Default toast with duration", duration).show();

Default toast with icon

Simple toast based on the vanilla Android theme with a icon for Toast.LENGTH_SHORT duration.

DynamicToast.make(context, "Default toast with icon", drawable).show();

Default toast with icon and duration

Simple toast based on the vanilla Android theme with a icon for supplied duration.

DynamicToast.make(context, "Default toast with icon and duration", drawable, duration).show();

Error toast

Error toast with #F44336 background for Toast.LENGTH_SHORT duration.

DynamicToast.makeError(context, "Error toast").show();

Error toast with duration

Error toast with #F44336 background for supplied duration.

DynamicToast.makeError(context, "Error toast with duration", duration).show();

Success toast

Success toast with #4CAF50 background for Toast.LENGTH_SHORT duration.

DynamicToast.makeSuccess(context, "Success toast").show();

Success toast with duration

Success toast with #4CAF50 background for supplied duration.

DynamicToast.makeSuccess(context, "Success toast with duration", duration).show();

Warning toast

Warning toast with #FFEB3B background for Toast.LENGTH_SHORT duration.

DynamicToast.makeWarning(context, "Warning toast").show();

Warning toast with duration

Warning toast with #FFEB3B background for supplied duration.

DynamicToast.makeWarning(context, "Warning toast with duration", duration).show();

Custom toast

Custom toast based on the supplied background and tint color for Toast.LENGTH_SHORT duration.

DynamicToast.make(context, "Custom toast", tintColor, backgroundColor).show();

Custom toast with duration

Custom toast based on the supplied background and tint color for supplied duration.

DynamicToast.make(context, "Custom toast with duration", tintColor, backgroundColor, duration).show();

Custom toast with icon

DynamicToast.make(context, "Custom toast with icon", drawable, tintColor, backgroundColor).show();

Custom toast with icon and duration

Custom toast based on the supplied icon, background and tint color theme for supplied duration.

DynamicToast.make(context, "Custom toast with icon and duration", drawable, 
        tintColor, backgroundColor, duration).show();

Cheat sheets

Use DynamicHint.show(view, toast) method to display it according to the anchor view position.

Full Example

Click the link below to see a full example of how to use this library.

Read more Read More.


5. CookieBar

CookieBar is a lightweight library for showing a brief message at the top or bottom of the screen..

CookieBar is a lightweight library for showing a brief message at the top or bottom of the screen.

Screenshot

Toast Library Tutorial

Toast Library Tutorial

Step 1: Install

Install the library using the following implementation statement:

dependencies {
    implementation 'com.liuguangqiang.cookie:CookieBar:1.0.1'
}

via Maven:

<dependency>
  <groupId>com.liuguangqiang.cookie</groupId>
  <artifactId>CookieBar</artifactId>
  <version>1.0.1</version>
  <type>pom</type>
</dependency>

Step 2: Use

Use it as shown in the below examples:

A simple CookieBar.

new CookieBar.Builder(MainActivity.this)
                        .setTitle("TITLE")
                        .setMessage("MESSAGE")
                        .show();

A CookieBar with a icon and a action button.

new CookieBar.Builder(MainActivity.this)
                        .setTitle("TITLE")
                        .setIcon(R.mipmap.ic_launcher)
                        .setMessage("MESSAGE")
                        .setAction("ACTION", new OnActionClickListener() {
                            @Override
                            public void onClick() {
                            }
                        })
                        .show();

Styling

You can change the default style by set the Theme's attributes.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
   <item name="cookieTitleColor">@color/default_title_color</item>
   <item name="cookieMessageColor">@color/default_message_color</item>
   <item name="cookieActionColor">@color/default_action_color</item>
   <item name="cookieBackgroundColor">@color/default_bg_color</item>
</style>

Or dynamically change the style with a cookie builder. Use the following properties:

  • layoutGravity
  • backgroundColor
  • titleColor
  • messageColor
  • actionColor
  • duration

Full Example

Let us look at a full CookieBar Toast Library Example below.

Read more Read More.


6. Toaster-android

A simple library to add custom toast to android applications..

Toast Library Tutorial

Toast Library Tutorial

Toast Library Tutorial

Toast Library Tutorial

Toast Library Tutorial

Step 1: Declare Jitpack

Add the JitPack repository to your build.gradle(project).

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Step 2: Add Dependency

Add the dependency to your build.gradle(Module: app).

dependencies {
    implementation 'tech.developingdeveloper.toaster-android:toaster:2.3.0'
    implementation 'tech.developingdeveloper.toaster-android:toaster-ktx:2.3.0' //for ktx support
}

Please Note: toaster-ktx includes toaster module so, if you are using toaster-ktx version then you don't have to add taoster

Step 3: Use

Video:

Toast Library Tutorial

A simple use case will look like this

Toaster.pop(
             this,
             "A simple toast message"
         ).show()

With a custom drawable

Toaster.pop(
              this,
              "A simple toast message with image",
              R.drawable.ic_baseline_cloud_done_24 /* image */
          ).show()

Toast Library Tutorial

Code Snippets

Using templates

  • Success
Toaster.popSuccess(
                  this,
                  "This is a success message",
                  Toaster.LENGTH_SHORT
              ).show()

Toast Library Tutorial

  • Warning
Toaster.popWarning(
              this,
              "This is a warning message",
              Toaster.LENGTH_SHORT
          ).show()

Toast Library Tutorial

  • Error
Toaster.popError(
              this,
              "This is an error message",
              Toaster.LENGTH_SHORT
          ).show()

Toast Library Tutorial

Custom Toast

val toastBuilder = Toaster.Builder(this)
              .setMessage("File uploaded successfully")
              .setLeftDrawable(R.drawable.ic_baseline_cloud_done_24)
              .setLeftDrawableTint(R.color.blue)
              .setStripTint(R.color.blue)
              .setDuration(Toaster.LENGTH_SHORT)
Toaster.pop(toastBuilder.make()).show()

Toast Library Tutorial

Custom Toast (toaster-ktx)

With the toaster-ktx, you can either make Taoster or directly create Toast with the provided functions.

  • Create Taoster usign ktx
val toaster = ToasterBuilderKtx.prepareToaster(this) {
    message = "File uploaded successfully"
    leftDrawableRes = R.drawable.ic_baseline_cloud_done_24
    leftDrawableTint = R.color.blue
    stripTint = R.color.blue
    duration = Toaster.LENGTH_SHORT
}
Toaster.pop(toaster).show()
  • Pop the Toast
Toaster.pop(toaster).show()
ToasterBuilderKtx.prepareToast(this) { 
        message = "File uploaded successfully" 
        leftDrawableRes = R.drawable.ic_baseline_cloud_done_24
        leftDrawableTint = R.color.blue
        stripTint = R.color.blue
        duration = Toaster.LENGTH_SHORT
}.show()

Toast Library Tutorial

Full Example

For a full Toaster Toast Library example project follow the following steps.

Read more Read More.


7. FloatingToast

Android library to create customizable floating animated toasts like in Clash Royale app. An android library to make customisable floating animated toasts. To use it…Read more Read More.

8. Hamadakram/Sneaker

A lightweight Android library for customizable alerts.

Here are demos:

Sneaker Example Tutorial

Step 1: Install it

Grab via Gradle:

implementation 'com.irozon.sneaker:sneaker:2.0.0'

Step 2: Usage

In Sneaker 2.0.0 it's possilbe to show sneaker on Activity, Fragment or any ViewGroup

Sneaker.with(activity) // To show Sneaker on Activity
 Sneaker.with(fragment) // To show Sneaker on Fragment
 Sneaker.with(viewGroup) // To show Sneaker on ViewGroup

Custom:

Sneaker.with(actvitiy) // Activity, Fragment or ViewGroup
       .setTitle("Title", R.color.white) // Title and title color
       .setMessage("This is the message.", R.color.white) // Message and message color
       .setDuration(4000) // Time duration to show
       .autoHide(true) // Auto hide Sneaker view
       .setHeight(ViewGroup.LayoutParams.WRAP_CONTENT) // Height of the Sneaker layout
       .setIcon(R.drawable.ic_no_connection, R.color.white, false) // Icon, icon tint color and circular icon view
       .setTypeface(Typeface.createFromAsset(this.getAssets(), "font/" + fontName)); // Custom font for title and message
       .setOnSneakerClickListener(this) // Click listener for Sneaker
       .setOnSneakerDismissListener(this) // Dismiss listener for Sneaker. - Version 1.0.2
       .setCornerRadius(radius, margin) // Radius and margin for round corner Sneaker. - Version 1.0.2
       .sneak(R.color.colorAccent) // Sneak with background color

Error:

Sneaker.with(actvitiy) // Activity, Fragment or ViewGroup
        .setTitle("Error!!")
        .setMessage("This is the error message")
        .sneakError()

Success:

Sneaker.with(actvitiy) // Activity, Fragment or ViewGroup
        .setTitle("Success!!")
        .setMessage("This is the success message")
        .sneakSuccess()

Warning:

Sneaker.with(actvitiy) // Activity, Fragment or ViewGroup
        .setTitle("Warning!!")
        .setMessage("This is the warning message")
        .sneakWarning()

Custom View:

val sneaker = Sneaker.with(actvitiy) // Activity, Fragment or ViewGroup
 val view = LayoutInflater.from(this).inflate(R.layout.custom_view,  sneaker.getView(), false)
 // Your custom view code
 view.findViewById<TextView>(R.id.tvInstall).setOnClickListener{
       Toast.makeText(this, "Clicked", Toast.LENGTH_SHORT).show()
 }
 sneaker.sneakCustom(view)

Full Example

Follow these steps to create a full Sneaker Toast Library example.

Read more Read More.


9. marcoscgdev/MaterialToast

A fully and highly customizable material designed Toast for Android..

Here is a demo:

Toast Library Tutorial

Step 1: Adding the depencency

Add this to your root build.gradle file:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Now add the dependency to your app build.gradle file:

implementation 'com.github.marcoscgdev:MaterialToast:1.0.2'

Step 2: Creating a Toast

For Native version:

MaterialToast.makeText(activity, "Hello, I'm a material toast!", Toast.LENGTH_SHORT).show();

Also with custom icon:

MaterialToast.makeText(activity, "Hello, I'm a material toast!", R.mipmap.ic_launcher, Toast.LENGTH_SHORT).show();

And also with custom background color (text will be automatically colored based on background color):

MaterialToast.makeText(activity, "Hello, I'm a material toast!", R.mipmap.ic_launcher, Toast.LENGTH_SHORT).setBackgroundColor(Color.RED).show();

With custom duration (in millis):

MaterialToast.makeText(activity, "Hello, I'm a material toast!", R.mipmap.ic_launcher, 4000).setBackgroundColor(Color.RED).show();

Here is a complete code snippet:

new MaterialToast(activity)
       .setMessage("Hello, I'm a material toast!")
       .setIcon(R.mipmap.ic_launcher)
       .setDuration(Toast.LENGTH_SHORT)
       .setBackgroundColor(Color.RED)
       .show();

Full Example

Let us look at a full MaterialToast Library Example below.


Read more Read More.


10. Toasty

The usual Toast, but with steroids.

Toasty

Toast Library Tutorial

Toast Library Tutorial

The usual Toast, but with steroids.

Step 1: Declare Jitpack

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2: Add Dependency

Add this to your module's build.gradle file (make sure the version matches the JitPack badge above):

dependencies {
    ...
    implementation 'com.github.GrenderG:Toasty:1.5.2'
}

Step 3: Configuration

This step is optional, but if you want you can configure some Toasty parameters. Place this anywhere in your app:

Toasty.Config.getInstance()
    .tintIcon(boolean tintIcon) // optional (apply textColor also to the icon)
    .setToastTypeface(@NonNull Typeface typeface) // optional
    .setTextSize(int sizeInSp) // optional
    .allowQueue(boolean allowQueue) // optional (prevents several Toastys from queuing)
    .setGravity(int gravity, int xOffset, int yOffset) // optional (set toast gravity, offsets are optional)
    .supportDarkTheme(boolean supportDarkTheme) // optional (whether to support dark theme or not)
    .setRTL(boolean isRTL) // optional (icon is on the right)
    .apply(); // required

You can reset the configuration by using reset() method:

Toasty.Config.reset();

Step 4: Usage

Each method always returns a Toast object, so you can customize the Toast much more. DON'T FORGET THE show() METHOD!
show()
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();

Screenshots

Please click the image below to enlarge.
Toast Library Tutorial

Full Example

Awaiting below is a full android sample to demonstrate this Toast Library concept.

Read more Read More.