我需要创建一个弧形的进度条。我应该为此创建一个自定义视图吗?或者借助onDraw()
ProgressBar 类的方法,我可以执行此操作?我还想在这个进度条上添加标记,比如温度计。请建议我任何想法。谢谢。
像这样的东西:
protected synchronized void onDraw(Canvas canvas) {
int progress = this.getProgress();
int maxProgress = this.getMax();
//calc the progress to angles
float angleProgress = progress * 360 / maxProgress;
//create and set the arc paint
Paint arcPaint = new Paint();
arcPaint.setColor(0xff800000);
arcPaint.setAntiAlias(true);
arcPaint.setStyle(Style.FILL);
Rect arcRect = new Rect(); this.getDrawingRect(arcRect);
canvas.drawArc(new RectF(arcRect), -90, angleProgress,true, arcPaint);
}
对于参考检查此图像弧形进度条