android Toast工具BToast
16lz
2022-04-20
android Toast工具BToast
1,引用
implementation 'com.bravin.btoast:BToast:1.0.3'
2,在Application中配置
@Override public void onCreate() { super.onCreate(); BToast.Config.getInstance()// .setAnimate() // Whether to startAnimation. default is fasle;// .setAnimationDuration()// Animation duration. default is 800 millisecond// .setAnimationGravity()// Animation entering position. default is BToast.ANIMATION_GRAVITY_TOP// .setDuration()// toast duration is Either BToast.DURATION_SHORT or BToast.DURATION_LONG// .setTextColor()// textcolor. default is white// .setErrorColor()// error style background Color default is red// .setInfoColor()// info style background Color default is blue// .setSuccessColor()// success style background Color default is green// .setWarningColor()// waring style background Color default is orange// .setLayoutGravity()// whan show an toast with target, coder can assgin position relative to target. default is BToast.LAYOUT_GRAVITY_BOTTOM// .setLongDurationMillis()// long duration. default is 4500 millisecond// .setRadius()// radius. default is half of view's height. coder can assgin a positive value// .setRelativeGravity()// whan show an toast with target, coder can assgin position relative to toastself(like relativeLayout start end center), default is BToast.RELATIVE_GRAVITY_CENTER // .setSameLength()// sameLength. whan layoutGravity is BToast.LAYOUT_GRAVITY_TOP or BToast.LAYOUT_GRAVITY_BOTTOM,sameLength mean toast's width is as same as target,otherwise is same height // .setShortDurationMillis()// short duration. default is 3000 millisecond// .setShowIcon()// show or hide icon// .setTextSize()// text size. sp unit .apply(this);// must call }
3,使用,来展示个success类型的toast
BToast.success(v.getContext()) .text("this is text") .show();
再来个矩形toast
BToast.success(v.getContext()) .text(R.string.text_test_content) .radius(0) .show();
动画版toast
BToast.success(v.getContext()) .text(R.string.text_test_content) .animate(true) .show();
更多相关文章
- Android自定义属性
- android Rect的使用
- android onFling 事件没有用
- Android图片缓存加强版(LruCache+DiskLruCache+软引用)
- 赵雅智_Android的getResources()资源引用
- Android(安卓)shape中的padding无效
- 通过Titanium Studio为Android(安卓)APK签名
- 转:Android实现矩形设置菜单
- Android(安卓)Drawable 详解(教你画画!)