最近写了一个水滴效果的进度条,加了点特效,就是个简单的自定义view,用的二阶贝塞尔函数,如果有赶工期或者正好碰到类似效果需求的同伴们可以直接改改来用,提供 setProgress(float porgress)和reset()函数,已做适配,先上效果图:

然后直接上完整代码:
/**
* author by LiuGuo
* on 2021/4/9
* 自定义组件:水滴进度条
*/
public class DripProgressView extends View {
private int widthsize;
private int heightsize;
Context context;
DecimalFormat decimalFormat = new DecimalFormat("00");
public boolean isTart;
private Paint drip_paint;
private Paint reseve_line_paint;
private Paint text_paint;
private Path path0;
private Path path1;
private Path path2;
private Path path3;
private Path path4;
boolean isFinish;
float text_speech = 0; //文字掉下速度
int drip_speech = 0; //水滴掉下速度
float mDegrees = 0; //整体进度
float line_revese_radom = 0; //横线回弹随机数
Random random = new Random();
private int bglColor;
private int textColor;
public DripProgressView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
this.context = context;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.waterProgress);
bglColor = ta.getColor(R.styleable.waterProgress_bgColor, Color.parseColor("#33FF66"));
textColor = ta.getColor(R.styleable.waterProgress_textColor, Color.parseColor("#ffffff"));
}
public DripProgressView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {

本文介绍了一款使用二阶贝塞尔曲线实现的水滴效果进度条,提供了设置进度和重置的功能,并附带了完整的代码实现。通过自定义View,作者实现了动画效果,包括水滴下落和文字跟随下落的动态展示。同时,提供了attrs文件以自定义背景颜色和文字颜色。代码已在码云上开源。
最低0.47元/天 解锁文章
436

被折叠的 条评论
为什么被折叠?



