The usual Toast, but with steroids 💪

Last update: May 24, 2022

ko-fi

Toasty

API Android Arsenal

The usual Toast, but with steroids.

Prerequisites

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

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

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.0'
}

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)
    .apply(); // required

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

Toasty.Config.reset();

Usage

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

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

Extra

You can pass formatted text to Toasty!

There are variants of each method, feel free to explore this library.

Screenshots

Please click the image below to enlarge.

Third Party Bindings

React Native

You may now use this library with React Native via this module.

Apps using Toasty

Want to be here? Open an issue or make a pull request.

ColorHub - Color Palette
Daily – News flipped around
Oz! Comic Reader
Impactor Unroot
Fusemounter
BlueWords
Photo Map - Photo and Video Gallery
Maki for Facebook & Twitter
ModPE IDE
Rocket Notes
OpenHub for GitHub
openHAB
Saarang
Kad ce mi bus - red voznje
Hide Files
LogViewer for openHAB

GitHub

https://github.com/GrenderG/Toasty
Comments
  • 1. [Refactoring] Exude color variables to resources

    I think it will be better to move color variables into resource file.

    1. It will reduce code duplication

    2. it will increase readability, since I thought through code that warning and error colors are constants, also actualy they not

    3. It will give the user more flexibility to config toast. They will able to rewrite your color resources in their own complex resources files. Suppose, we have aaplication, that for different regions use different color schemes. With code-config-aproach it will request for library user more effort to adjust colors by config changes, that if colors were in resource file

    Reviewed by programmerr47 at 2018-02-27 05:21
  • 2. after adding your library in project these errors come up

    build error

    Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
    C:\Users\tariq\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\d8468f24b31c24ee8d29575dc26584f6\res\values-v26\values-v26.xml
    Error:(9, 5) error: resource android:attr/colorError not found.
    Error:(13, 5) error: resource android:attr/colorError not found.
    Error:(17, 5) error: style attribute 'android:attr/keyboardNavigationCluster' not found.
    C:\Users\tariq\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\d8468f24b31c24ee8d29575dc26584f6\res\values\values.xml
    Error:(252, 5) error: resource android:attr/fontStyle not found.
    Error:(252, 5) error: resource android:attr/font not found.
    Error:(252, 5) error: resource android:attr/fontWeight not found.
    C:\Users\tariq\Desktop\adnan laravel android pharamacy\materiallogindemo-master\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml
    Error:(7) resource android:attr/colorError not found.
    Error:(11) resource android:attr/colorError not found.
    Error:(15) style attribute 'android:attr/keyboardNavigationCluster' not found.
    C:\Users\tariq\Desktop\adnan laravel android pharamacy\materiallogindemo-master\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
    Error:(438) resource android:attr/fontStyle not found.
    Error:(438) resource android:attr/font not found.
    Error:(438) resource android:attr/fontWeight not found.
    Error:failed linking references.
    Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    Error:Execution failed for task ':app:processDebugResources'.
    > Failed to execute aapt
    Information:BUILD FAILED in 13s
    Information:17 errors
    Information:0 warnings
    Information:See complete output in console
    
    Reviewed by tjnapster555 at 2018-01-04 18:08
  • 3. Toast.LENGTH_LONG does not work on Android 7.1 in onCreate()

    Android OS version 7.1

    when I call Toasty in onCreate(), Toasty show only 1 sec. This probrem causes only Android 7.1. Toast.makeText(LENGTH_LONG).show() works fine.

    public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toasty.success(getApplicationContext(), "this toast show only 1 sec",  Toast.LENGTH_LONG).show(); // (A)
            }
        });
    
        Toasty.success(getApplicationContext(), "this toast show 4 sec", Toast.LENGTH_LONG).show(); // (B)
    
    
    
    }
    

    }

    Reviewed by nakawai at 2017-07-28 09:30
  • 4. Toast padding is being removed with fitsSystemWindows set to true.

    Hi @GrenderG , thanks for the great library! I have a question about how the text padding for Toasty is set. Usually, text in Toasty has a 16-20dp left right margin. However, when I am using the library in a fullscreen activity, the text padding disappears. What is setting the toast's text padding?

    P.S. I am currently adding spaces around my toast messages like " Toast Message " to simulate padding. It works great :D

    Reviewed by searchy2 at 2017-04-13 17:26
  • 5. Fatal Exception: ResourcesNotFoundException

    Crash when app trying init Toasty.warning ToastyUtils.getDrawable(context, drawable.ic_error_outline_white_48dp)

    I never see this issue before but after building as App bundle it's happens.

    screen shot 2018-09-30 at 13 01 02 pm
    Reviewed by DimaDDM at 2018-09-30 10:06
  • 6. No padding in toasty

    Great library, just having an issue with it which I think is a bug. When I create any type of Toasty the text and icon have no right or left padding. Using Android 7.1.1 on API 25.

    Reviewed by TobiPristupin at 2017-08-10 19:27
  • 7. v1.2.0 Removes Set Text Color, Why?

    Hi @GrenderG , This library is absolutely amazing and I am currently using it in 3 apps! Today when I upgraded from v1.1.5 to 1.2.0, the existing code broke because the set text color value was removed. Why was set text color removed? How is text color controlled now? Thank you for your great work!

    Reviewed by searchy2 at 2017-04-28 15:23
  • 8. Allow passing text as StringRes

    Current:

    Toasty.info(context, context.getString(R.string.foo), Toast.LENGTH_SHORT).show();
    

    Request:

    Toasty.info(context, R.string.foo, Toast.LENGTH_SHORT).show();
    
    Reviewed by mueller-ma at 2018-10-15 16:58
  • 9. Added Support for React Native Projects

    Hi @GrenderG,

    First of all I would like to appreciate for creating such a cool toast library.

    I have created a React Native bridge plugin for using this library with React Native projects.

    I have added the same in README. Can you please merge this request so that if someone looking to use this library for React Native projects can easily do the same.

    Please let me know in case any changes are required

    react-native-toasty

    Thanks Pranav

    Reviewed by prscX at 2018-06-22 05:02
  • 10. Toasty - show message from resource

    Android Toast can use string resources without converting to CharSequence or String: Toast.makeText(context, R.string.connection_lost, Toast.LENGTH_SHORT).show(); in Toasty only this way: Toasty.error(context, context.getString(R.string.connection_lost), Toast.LENGTH_SHORT, true).show(); Add the ability to use string resources without converting!

    Reviewed by Bramengton at 2018-04-25 13:57
  • 11. NullPointException shows when I make a toast

    java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference at android.widget.ToastInjector.addAppName(ToastInjector.java:50) at android.widget.Toast.makeText(Toast.java:269) at es.dmoral.toasty.Toasty.custom(Toasty.java:171) at es.dmoral.toasty.Toasty.warning(Toasty.java:100)

    Reviewed by EricZX123 at 2018-03-16 09:40
  • 12. Feature request: support text shadow - TextView.setShadowLayer(float radius, float dx, float dy, int colour)

    Small feature request - shadow underneath text (can be used for glow I suppose as well if you're into that kind of thing)

    Use case: Yellow background with white text, the default colours are difficult for some people to parse in low contrast environments quickly. Whilst changing the colours would also be better, legibility can be improved significantly by simply adding a shadow underneath the text

    So, access to .setShadowLayer(...) (a la TextView) would be nice :)

    Reviewed by piemmm at 2021-12-07 20:45
  • 13. ToastyUtils.java line 1 es.dmoral.toasty.ToastyUtils.getDrawable

    Fatal Exception: android.content.res.Resources$NotFoundException Resource ID #0x7f08009d

    Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x7f08009d at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:253) at android.content.res.Resources.getValue(Resources.java:1437) at androidx.appcompat.widget.ResourceManagerInternal.c(ResourceManagerInternal.java:18) at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:3) at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:2) at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:4) at es.dmoral.toasty.ToastyUtils.getDrawable(ToastyUtils.java:1) at es.dmoral.toasty.Toasty.success(Toasty.java:1) at es.dmoral.toasty.Toasty.success(Toasty.java:2)

    Reviewed by Younes-Charfaoui at 2021-11-09 21:42
  • 14. 内存泄漏问题

    由于是自定义view的toast,所以在传入context的时候,传入了activity。但是在实际操作中,activity可能已经被销毁,从而导致内存泄漏。 if (!allowQueue){ if (lastToast != null) lastToast.cancel();//这里的lastToast可能持有一个已经销毁的activity对象。建议优化 lastToast = currentToast; }

    Reviewed by aillience at 2021-10-19 09:31
A library that extends the Android toast framework.
A library that extends the Android toast framework.

SuperToasts Library The SuperToasts library enhances and builds upon the Android Toast class. This library includes support for context sensitive Supe

May 13, 2022
In-layout notifications. Based on Toast notifications and article by Cyril Mottier (http://android.cyrilmottier.com/?p=773).
In-layout notifications. Based on Toast notifications and article by Cyril Mottier (http://android.cyrilmottier.com/?p=773).

Android AppMsg (Crouton) Library Implementation of in-layout notifications. Based on Toast notifications and article The making of Prixing #4: in-layo

May 19, 2022
An Android Toast replacement, similar to the one seen in the GMail app.

MessageBar An Android Toast replacement, similar to the one seen in the GMail app. Multiple messages can be posted in succession, and each message wil

Feb 16, 2022
🍞 The missing toast library for Android.
🍞 The missing toast library for Android.

Literally Toast ?? A toast library for Android. Usage: ?? Use the LitToast to get lit and show your users a proper toast. LitToast.create(context, "My

Dec 17, 2021
Toastie is a customizable Android toast library.
Toastie is a customizable Android toast library.

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

Apr 3, 2021
A really simple library that help you to display a custom toast with many colors (for : success, warning, danger, info, dark, light, primary...etc ), or with rounded corners, or event with image.

CoolToast A really simple library that help you to display a custom toast with many colors (for : success, warning, danger, info, dark, light, primary

Jun 22, 2020
Android Custom Toast
Android Custom Toast

Super Toast Library Written Purely in Kotlin ❤️ Usual Toast but with super powers!!! ?? A Fully Customised and Customisable Toast. ]( https://android-

May 2, 2021
Android Toast For RTL Applications
Android Toast For RTL Applications

RTL-Toast Android library to show Toasts in a pretty RTL way Install Add it in your root build.gradle allprojects { repositories { ... ma

Oct 19, 2021
Attractive, stylish and customizable toast library for Android.

FabToast min SDK 16 (Jelly Bean 4.1) written in Java To download the demo app for this library from Google Playstore so you can see it in action, clic

Feb 14, 2022
Simple toast

newlibrary Simple toast Step 1. Add the JitPack repository to your build file allprojects { repositories { ... maven { url 'https://jitpack.io

Nov 5, 2021
An easy, flexible way to have the toast message displayed.
 An easy, flexible way to have the toast message displayed.

IToaster Library An easy, flexible way to have the toast message displayed. Download Gradle Add below codes to your root build.gradle file (not your m

Mar 19, 2022
Custom Toast Library by Google Developer Student Club University of Brawijaya
Custom Toast Library by Google Developer Student Club University of Brawijaya

GDSCToast Custom Toast Library by Google Developer Student Club University of Brawijaya Prerequisites For old version of gradle (before arctic fox upd

May 22, 2022
Customizable toast message library for Android
Customizable toast message library for Android

Android Custom Toast Message (SnToast) Customizable Toast Message Library For Android Add this in your root build.gradle file allprojects { reposito

Nov 15, 2021
MDToast - MaterialDesign Toast library written with Kotlin with lots of extensions to interact easily in contexts
MDToast - MaterialDesign Toast library written with Kotlin with lots of extensions to interact easily in contexts

MDToast - MaterialDesign Toast A lightweight Toast library written with Kotlin i

Apr 22, 2022
Android : IamToast Another Toast library for Android
 Android : IamToast  Another Toast library for Android

Android : IamToast Another Toast library for Android Warning. toast custom view is deprecated since android 11(R) Setup allprojects { repositories

Feb 7, 2022
The usual Snackbar with more 🍫 and colours :tada:
The usual Snackbar with more 🍫 and colours :tada:

ChocoBar The usual Snackbar with more ?? and colours ?? . Inspired by Light. GIF AndroidPub Post You can read the AndroidPub post about this library,

Dec 8, 2021
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.
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.

FancyToast-Android Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ... ma

May 19, 2022
CuteToast is an Material Design Custom Toast for Android | Custom Material Design Toast
CuteToast is an Material Design Custom Toast for Android | Custom Material Design Toast

CuteToast is an Android Custom Toast library that could be used instead of Default Toast. It does everything as Toast but with some extra spice.

Dec 14, 2021
A library that extends the Android toast framework.
A library that extends the Android toast framework.

SuperToasts Library The SuperToasts library enhances and builds upon the Android Toast class. This library includes support for context sensitive Supe

May 13, 2022
In-layout notifications. Based on Toast notifications and article by Cyril Mottier (http://android.cyrilmottier.com/?p=773).
In-layout notifications. Based on Toast notifications and article by Cyril Mottier (http://android.cyrilmottier.com/?p=773).

Android AppMsg (Crouton) Library Implementation of in-layout notifications. Based on Toast notifications and article The making of Prixing #4: in-layo

May 19, 2022