1. 程式人生 > >第三方開源庫:Toast工具:Toasty

第三方開源庫:Toast工具:Toasty

效果圖:

這裡寫圖片描述

配置

Project的build.gradle

repositories {
    maven { url "https://jitpack.io" }
    jcenter()
}

module的build.gradle

dependencies {
    ...
    compile 'com.github.GrenderG:Toasty:1.1.2'
}

使用

原生

Toasty.normal(context, "normal").show();

原生 + icon

Toasty.normal(context, "normal+icon"
, Toast.LENGTH_SHORT, getResources().getDrawable(R.mipmap.ic_launcher), true).show();

普通

Toasty.info(context, "info").show();

成功

Toasty.success(context, "success").show();

警告

Toasty.warning(context, "warning").show();

失敗

Toasty.error(context, "error").show();

自定義

Toasty.custom
(context, "cutstom", getResources().getDrawable(R.mipmap.ic_launcher),getResources().getColor(R.color.color1) , getResources().getColor(R.color.color2), Toast.LENGTH_SHORT, true, true).show();

原始碼