一、目标
实现圆环进度条,为神马笔记播放笔记的录音元素做准备。
二、参考项目
开源项目 | 描述 |
---|---|
ldoublem / RingProgress | a circle progress bar with effect |
HotBitmapGG / RingProgressBar | A material design circle the progress bar. |
三、系统功能类
类 | 描述 |
---|---|
ShapeDrawable | 使用各种Shape的Drawable。 |
ArcShape | A material design circle the progress bar. |
四、实现代码
添加了start()
和stop()
接口,使之产生动画效果。
public class RingView extends View {
long duration;
long progress;
long startTime;
long endTime;
boolean isRunning;
ShapeDrawable drawable;
RingShape shape;
float indentSize;
public RingView(Context context) {
this(context, null);
}
public RingView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public RingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public RingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
{
this.shape = new RingShape(-90, 0);
this.drawable = new ShapeDrawable(shape);