A library that extends the Android toast framework.

Last update: May 13, 2022

SuperToasts Library

Download

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.

Screenshot

Adding SuperToasts to your project

SuperToasts are now available on Jcenter. Add the following to your module's build.gradle file:

dependencies {
    compile 'com.github.johnpersano:supertoasts:2.0'
}

Using the library

Simple sample:

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

Check out the Wiki pages* for more detailed samples.
*Please note that the Wiki pages are still being updated and may not reflect the most recent changes in version 2.0.

Demo Application

A simple demo application is available on Google Play. This demo application does not showcase all of the libraries functions rather it is a short demonstration of major features of the library.

Android app on Google Play

Considerations

Some of the ideas for this library came from the UndoBar Library and the Crouton Library.

Developer

John Persano

License

Copyright 2013-2016 John Persano

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

GitHub

https://github.com/JohnPersano/SuperToasts
Comments
  • 1. Using MetricAffectSpans to get different typeface leads to wrong padding

    Because of the missing Typeface-setting option, I tried a real clue: Setting texts using SpannableStrings that include a different MetricAffectingSpan (see http://stackoverflow.com/a/15181195/273456)

    But when doing that, the padding around the text gets really small, the toasts become extremely thin... Could you help?

    Reviewed by Zordid at 2014-01-30 13:25
  • 2. Naming conventions

    I notice, that the naming conventions of member fields, local variables and parameters are wildly mixed in the code.

    In Android, it's convention to use the prefix "m" for member fields only, not for local variables. In your code, sometimes you have member fields without any prefix but also some local variables have an "m" prefix.

    Makes your code hard to read and understand. I would offer help, but I am new to github and don't know how to contribute...

    Reviewed by Zordid at 2013-07-07 10:34
  • 3. Is the repository dead?

    Hey,

    Thanks for sharing! I'm just curious if the repository is still maintained. If not, it would be great to know it in order to switch to another toast framework.

    Cheers! :panos

    Reviewed by le4ker at 2016-06-19 20:35
  • 4. Floating SuperCardToast?

    Have you thought in adding a 'floating' style to SuperCardToasts? Something like what Crouton does. I really like SuperCardToast and the customization possibilities, but two things made me finally discard it:

    • The need to add a new layout in my root view
    • Because SuperCardToast moves everything down, if working with lists this forces the adapter to repaint (and remeasure) everything over and over.

    It would be nice to have the possibility to display the card over the current layout

    Reviewed by lgvalle at 2014-05-18 21:29
  • 5. Why onTouchListener for button click?

    Using SuperCardToasts with buttons isn't working so well for me in 1.3.2.

    The button seems to have an OnTouchListener that dismisses the toast before the wrapped OnClickListener is called.

    Why are you using Touch listeners instead of Click listeners for the button?

    Reviewed by myanimal at 2014-02-11 15:52
  • 6. How to transport information for OnClickWrappers?

    Hi John! Well, now I see how you want to "restore" OnClickListeners for Buttons in Toasts - using the Wrapper classes and a tag. But your example case is too simple: how should I transport information to my potentially restored OnClickListener between orientation changes? In your demo it is clear that the "potentially destructive action" which gives a toast with a button cannot use any context data, like what should restored when the button is clicked! ...that is one reason why I do not like the restoring of toasts at all! In my use cases, I create an OnClickListener class that inherently "knows" which data is to be worked on, just because I use inner classes. That cannot be done using your model at all. What is needed is a way to maybe also give a bundle to the Wrapper for each use of the toast - and that will have to be restored on orientation change as well... See what I mean? Thanks! Olaf

    Reviewed by Zordid at 2014-02-10 09:28
  • 7. Decomposition required

    Right now there's five completely unrelated classes. Though works fine they're too large and difficult to read. A lot of code duplication can also be avoided. It would be great to introduce some hierarchy and maybe couple interfaces...

    Reviewed by RomanZhilich at 2013-07-01 11:51
  • 8. setGravity() for SuperActivitiyToast

    I would like to slightly adjust the position of a SuperActivityToast, but it doesn't seem to have a setGravity() method, like SuperToast does. Can this be added?

    Reviewed by justbbetter at 2014-10-20 22:26
  • 9. Request: Please remove unused resources from the library project

    For example "dummy_layout.xml" . If you just need its id to be declared, just declare an id in a "ids.xml" file.

    In order to find all of the unused resources, I suggest to run Lint (and on the way to also check other warnings of it).

    Reviewed by AndroidDeveloperLB at 2014-09-23 14:38
  • 10. SuperActivityToast now showing (and not clickable) occasionally ?

    I am using SuperActivityToast to show a confirmation with an optional info button (which launches another activity).

    Occasionally the toast doesn't come up. Occasionally it comes up but the button is not clickable. Noticed this happens when we try using it frequently. I am using it from a fragment. Any clues ?

    Code below:

        subscribeConfirmationToast = new SuperActivityToast(getActivity(), SuperToast.Type.BUTTON);
        subscribeConfirmationToast.setTouchToDismiss(true);
        subscribeConfirmationToast.setText(getResources().getString(R.string.button_subscribe_confirmation));
        subscribeConfirmationToast.setButtonIcon(R.drawable.ic_action_database, 
                getResources().getString(R.string.page_title_subscribed));
        subscribeConfirmationToast.setDuration(SuperToast.Duration.SHORT);
        subscribeConfirmationToast.setOnClickWrapper(new OnClickWrapper(this.getClass().getName(), new OnClickListener() {
            @Override
            public void onClick(View view, Parcelable token) {
                SuperActivityToast.cancelAllSuperActivityToasts();
                EventBus.getDefault().post(new Event.ShowMyShowsClicked(getActivity()));    // This will launch another activity.           
            }
        }));
    
    public void onEventMainThread(Event.ShowSubscribed event) {
        // some other UI updations
        if(subscribeConfirmationToast != null) {
            subscribeConfirmationToast.show();
        }
       }
    
    Reviewed by skadavan at 2014-07-12 07:43
  • 11. SuperCardToast with ViewPager

    I've a Fragment that holds a ViewPager. This ViewPager has 2 fragments (let's call them, "FragmentA" and "FragmentB" as tabbed views.

    Both FragmentA and FragmentB have:

    As root on their XML layout. When FragmentB is on the screen and the user presses something in there to fire a Toast the Toast is displayed, always, on FragmentA (which is not visible to the user) and not in the FragmentB (where the user is).

    It should fire the Toasts in the "on screen" fragment.

    Is this a bug? I can't find out a solution for this and I can't find anything on google regarding this issue.

    Reviewed by dazito at 2014-07-08 12:03
  • 12. Gravity doesn't work when style.TYPE_BUTTON is used

    Hi am trying to add gravity in main activity, applying

    .setGravity(Gravity.TOP) takes the toast out of the screen.

    I tried adding position with the gravity and it doesnt work

     position_x = (int) (CommonClass.width * 0.24);
    position_y = (int) (CommonClass.height * 0.18);
    
    
     SuperActivityToast.create(activity, new Style(), Style.TYPE_BUTTON)
                            .setButtonText("UNDO")
                            .setButtonIconResource(R.drawable.ic_home_black_24dp)
                            .setProgressBarColor(Color.WHITE)
                            .setText(s)
                            .setGravity(Gravity.TOP,position_x,position_y)
                            .setDuration(Style.DURATION_VERY_SHORT)
                            .setFrame(Style.FRAME_STANDARD)
                            .setColor(this.getResources().getColor(R.color.bluetoast))
                            .setPriorityLevel(Style.PRIORITY_HIGH)
                            .setAnimations(Style.ANIMATIONS_POP).show();
    

    is there any possibility that i could toast by setting offset in x and y using TYPE_BUTTON?

    Reviewed by Surakshaajith at 2020-03-06 07:02
  • 13. cannot resolve symbol 'Style'

    import com.github.johnpersano.supertoasts.library.Style; import com.github.johnpersano.supertoasts.library.SuperActivityToast; how to resolve cannot resolve symbol 'Style' ?? and resolve cannot resolve symbol 'SuperActivityToast' ??

    Thanks and regard Sondang

    Reviewed by sondangpangrib at 2018-08-14 12:20
  • 14. Obsolete version overriding

    Hello!

    I'm working with old project (about 2014 y) which is using SuperToasts. I want to override to its latest 2.0 version, but there's a problem that all of methods are changed. You're so lucky man, I have no so much time for totally rewrite my libraries which is working well. So, Wiki's is so old, so can I ask you about newest alternatives?

    1. setOnButtonClickListener () What we need to add to the third argument of it? And what is second one? Trying to add OnButtonClickListener method, but it's an abstract.
    2. How is setOnDismissWrapper () method called now? I need it because there's widget repaint needed on this action.
    3. Now new setButtonIconResource () accept only one method, so the second one is not needed which was needed in old setButtonIcon () method?

    Thanks in advance!

    Reviewed by ointeractive-depot at 2018-03-26 18:11
Related tags
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 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
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
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
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
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
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
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
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
The usual Toast, but with steroids đŸ’Ē
The usual Toast, but with steroids đŸ’Ē

Toasty The usual Toast, but with steroids. Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { r

May 24, 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
An android library for easy implementation of Toasts in Android with easy customisation.
An android library for easy implementation of Toasts in Android with easy customisation.

ToastTypeDecore Šī¸ A library for easy implementation of Toasts in Android with easy customisation. Latest Version : v2.1 Screenshots Success Toast1 Su

Oct 27, 2021
Android library to create customizable floating animated toasts like in Clash Royale app

FloatingToast-Android An android library to make customisable floating animated toasts Getting Started In your build.gradle dependencies { impleme

Mar 9, 2022
A tooltip/showcase library for Android re-written in Kotlin.

UglyTooltip Based on another Showcase library. Being kotlinized, customized and refactored.

Apr 27, 2022
Context sensitive notifications for Android
Context sensitive notifications for Android

Crouton Context sensitive notifications for Android DEPRECATION NOTICE This library has passed it's prime and is now considered deprecated. With the A

May 11, 2022