/**
* 绘制当前的圆弧
* @param canvas
*/
private void drawArc(Canvas canvas) {
//绘制圆弧背景
float x = (getWidth() - getHeight() / 2) / 2;
float y = getHeight() / 4;
RectF mRectF = new RectF( x, y,
getWidth() - x, getHeight() - y);
canvas.drawArc(mRectF,startAngle,mAngle,false,mArcPaint);
//绘制当前数值对应的圆弧
mArcPaint.setColor(Color.parseColor("#FF4A40"));
//根据当前数据绘制对应的圆弧
RectF mRectF1 = new RectF(x+80, y+80,getWidth() - x-80, getHeight() - y-80);
canvas.drawArc(mRectF1,startAngle,mAngle,false,mArcPaintthree);
canvas.drawArc(mRectF1,startAngle,mIncludedAngle,false,mArcPaintTow);
canvas.drawLine(x,getHeight()/2,x+40,getHeight()/2,mpointerPaint);//画线刻度
canvas.drawLine(getWidth()-40-x,getHeight()/2,
getWidth()-x,getHeight()/2,mpointerPaint);//画线刻度
canvas.drawLine(getWidth()/2,getHeight()/4,getWidth()/2,getHeight()/4+40,mpointerPaint);//画线刻度
canvas.drawLine(getWidth()/2,getHeight() - y,getWidth()/2,getHeight() - y-40,mpointerPaint);//画线刻度
canvas.drawLine(0,getHeight()/2,getWidth(),getHeight()/2,levelPaint);//水平线
canvas.save();//先保存之前的
canvas.rotate(mIncludedAngle,getWidth()/2, getHeight()/2);//延中心点旋转角度
canvas.drawLine(x,getHeight()/2,getWidth()-40-x,getHeight()/2,mpointerPaint);//画线
canvas.restore();//恢复
}
|