接下来算是我们的重中之重啦,根据上面分析的来绘制,对应的状态图,定义方法private void drawStepStateImg(Canvas canvas, int w, int h),代码为

@Override
protected void onDraw(Canvas canvas) {
int w = getWidth() - getPaddingLeft() - getPaddingRight() - maxImgXRadio * 2;
int h = getHeight() - getPaddingTop() - getPaddingBottom();
canvas.translate(getPaddingLeft() + maxImgXRadio, getPaddingTop());
drawBaseLine(w, h, canvas);
drawStepStateImg(canvas, w, h);
}

private void drawStepStateImg(Canvas canvas, int w, int h) {
for (int i = 1; i <= stepCount; i++) {
if (step < i) {
if (step == (i - 1)) {
canvas.drawBitmap(certification_ing_img, w * 1f * (i - 1) / (stepCount - 1) - maxImgXRadio, completeTop(h, certification_ing_img), mPaint);
} else {
canvas.drawBitmap(certification_not_finish_img, w * 1f * (http://www.amjmh.com) / (stepCount - 1) - certification_not_finish_img.getWidth() / 2.0f, completeTop(h, certification_not_finish_img), mPaint);
}
} else {
canvas.drawBitmap(certification_ing_img, w * 1f * (i - 1) / (stepCount - 1) - maxImgXRadio, completeTop(h, certification_ing_img), mPaint);
canvas.drawBitmap(certification_finish_img, w * 1f * (i - 1) / (stepCount - 1) - certification_finish_img.getWidth() / 2.0f, completeTop(h, certification_finish_img), mPaint);
}
}
}

--------------------- 

posted @ 2019-08-03 19:22  李艳艳665  阅读(152)  评论(0编辑  收藏  举报