android Toast工具BToast
16lz
2021-01-23
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标准Glide加载圆形图和圆角矩形图
- Android画圆角矩形图片,并在图片上写字
- Android 自定义Drawable 实现圆角矩形和圆形图片
- xml中设置圆角矩形框
- Android 快速将一个Bitmap变成圆形或圆角矩形 kotlin
- android 自定义相机 取矩形内内容 注意事项
- canvas.drawRoundRect方法,绘制圆角矩形
- a64_7.1-v3.1android拉伸绘制矩形区域距离默认平板外边界问题