Android封装实现各种功能的Toast
GitHub地址:https://github.com/SibreiaDante/ToastUtils
效果图:
方法封装如下:
showSingletonLong(String content):Toast文本,单例,长时间 showSingletonShort(String content):Toast文本,单例,短时间 showTextShort(String content):Toast文本,非单例,短时间 showTextLong(String content):Toast文本,非单例,长时间 showSingletonText(String content,int duration,int position ):Toast文本,自定义时长、位置 showSingletonImageCenter(int resId, int duration): Toast一张图片,单例,居中 showImageCenter(int resId,int duration):Toast一张图片,非单例,居中 showSingletonImage(int resId, int duration, int position):Toast一张图片,单例,自定义位置 showImage(int resId, int duration, int position):Toast一张图片,非单例,自定义位置 showImage(Bitmap bitmap, int duration, int position):Toast一张图片,非单例,自定义位置 showITSingleton(int resId, String content, int duration, int position):Toast图文,单例,自定义时长,自定义位置 showIT(int resId, String content, int duration, int position):Toast图文,非单例,自定义时长,自定义位置 showLines(List contents, int size):Toast 多行文本 非单例 showSingletonLines(List contents, int size):Toast 多行文本 单例 showLayout(View view, int duration, int position):Toast 自定义布局 非单例 howSingletonLayout(View view, int duration, int position):Toast 自定义布局 单例 showThread(String url):异步线程下载图片并Toast cancel():取消一个Toast,当弹出多个toast时,只会在最后一次toast被创建时取消 cancelAll():取消创建的所有的toast
使用说明:
第一步,在你的工程中
allprojects { repositories { ... maven { url 'https://jitpack.io' } } } dependencies { compile 'com.github.SibreiaDante:SiberiaDanteLib:v1.0.0' }
第二部,在你的项目中初始化
ToastApp.initToastUtils(getApplicationContext());