mCirclePaint = new Paint(); mCirclePaint.setAntiAlias(true); mCirclePaint.setStrokeWidth(CIRCLE_LINE_WIDTH); mCirclePaint.setStyle(Paint.Style.STROKE); mCirclePaint.setColor(ContextCompat.getColor(context, R.color.circle_color)); mCircleInnerPaint = new Paint(); mCircleInnerPaint.setAntiAlias(true); mCircleInnerPaint.setStyle(Paint.Style.FILL); mCircleInnerPaint.setColor(ContextCompat.getColor(context, R.color.circle_inner_color)); mTextPaint = new TextPaint(); mTextPaint.setAntiAlias(true); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setTypeface(Typeface.DEFAULT_BOLD); mTextPaint.setColor(ContextCompat.getColor(context, R.color.circle_text_color)); mTextPaint.setTextSize(TEXT_SIZE);
public void setProgress(float progress) {
if (progress > 100) {
progress = 100;
}
if (progress < 0) {
progress = 0;
}
mProgress = progress;
mProgressText = "Pause";
mStartProgress = true;
postInvalidate();
}
private void startProgress() {
new Thread() {
@Override
public void run() {
super.run();
float currentProgress = mCustomView.getCurrentProgress();
++currentProgress;
mCustomView.setProgress(currentProgress);
try {
sleep(30);
if (currentProgress <= 100) {
startProgress();
} else {
mCustomView.progressFinished();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
}
float halfWidth = getMeasuredWidth() / 2;
float halfHeight = getMeasuredHeight() / 2;
if (null == mCircleRectF) {
mCircleRectF = new RectF(halfWidth - CIRCLE_RADIUS, halfHeight - CIRCLE_RADIUS, halfWidth + CIRCLE_RADIUS, halfHeight + CIRCLE_RADIUS);
}
if (mStartProgress) {
float swipeProgress = mProgress / 100f * 360;
LogUtils.e("swipeProgress = " + swipeProgress);
canvas.drawArc(mCircleRectF, -90, swipeProgress, true, mCirclePaint);
} else {
canvas.drawCircle(halfWidth, halfHeight, CIRCLE_RADIUS,mCirclePaint);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有