Andoid CustomCircleProgress 半圆
package com.play.playgame.view; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.util.AttributeSet; import android.view.View; /** * Created by admin on 2017/8/10. */ public class CustomCircleProgress extends View { private Paint mPaint; private Context context; /** * 圆的宽度 */ private int mCircleWidth = 3; public CustomCircleProgress(Context context) { this(context, null); } public CustomCircleProgress(Context context, AttributeSet attrs) { this(context, attrs, 0); this.context = context; } public CustomCircleProgress(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mPaint = new Paint(); } protected void onDraw(Canvas canvas) { mPaint.setAntiAlias(true);//取消锯齿 mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(mCircleWidth); mPaint.setColor(Color.parseColor("#BEBEBE")); /** * 这是一个居中的圆 */ RectF oval = new RectF(0, 0, 2*getWidth(), getHeight()); canvas.drawArc(oval, 90, 180, false, mPaint); } }