//进度条的宽高
private int mWidth, mHeight;
/**
- 画进度条的矩形
*/
private RectF mRectF;
public ColorGradientProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView();
}
public ColorGradientProgressBar(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ColorGradientProgressBar(Context context) {
this(context, null);
}
private void initView() {
mPaint = new Paint();
mPaint.setAntiAlias(true);
mRectF = new RectF();
BORDER_STROCK = getResources().getDimension(R.dimen.x3);
PROGRESS_STROCK = getResources().getDimension(R.dimen.x5);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int round = mHeight / 2;//弧度为高度的一半
<