This is probably the best performing, easiest to use, customizable, no-notice-bar toast

Github shipping address, welcome Star

Has been invested in the company project, no problems, can be competent for any requirements, click here to download the Demo

ToastUtils source code: ToastUtils source code

The integration steps

Dependencies {implementation 'com.hjq: 0}Copy the code

Initialize the Toast

// Initialize toastutils.init (this) in Application;Copy the code

According to Toast

Toastutils.show (" I am toast ");Copy the code

Get a Toast object

ToastUtils.getToast();
Copy the code

Set Toast layout

ToastUtils.setView();
Copy the code

Custom Toast styles

If you are not satisfied with the default Toast style, you can initialize the style in the Application. For details, see the implementation of the ToastBlackStyle class

ToastUtils.initStyle(new IToastStyle());
Copy the code

The framework highlights

  • No permission required: Whether or not the notification bar permission is granted does not affect the pop-up of toast

  • Powerful: can pop up Toast regardless of primary or secondary threads, automatically distinguish resource ID and int type

  • Easy to use: just pass in the text and the length of the toast display will be automatically determined according to the length of the text

  • Best performance: singleton Toast, the entire Toast has only one TextView and is created in code

  • Optimal experience: Limit the number of pop-up Toast in a short period of time to avoid bad user experience caused by frequent pop-up Toast

  • Support a variety of styles: the default is black style, night mode can use white style, and imitation QQ toast style

  • Support custom styles: Toast (background, rounded corner, center of gravity, offset), text (size, color, margin)

  • Support for custom extensions: Support for retrieving Toast objects in ToastUtils and redefining the Toast layout

  • Support for global configuration styles: The Toast style can be initialized in the Application to achieve the effect once and for all

  • The framework is compatible: the framework does not rely on any third party libraries and supports the integrated use of Eclipse and Studio

About notification bar permissions

This framework has perfectly solved this problem (after disabling the permission of the notification bar, you need to restart the application to take effect, please test mainly by Demo)

The specific solution can be seen in: Toast Notification bar permission filling guide

Android Technology discussion Q group: 78797078

Remember to like + at the endStar