我想用斜线来实现进度条的效果。
我可以这样自定义进度条吗? 或者我必须在画布上画画?
我开始在画布上做,但后来我意识到我做错了什么
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int width = getMeasuredWidth();
int height = getMeasuredHeight();
mPaint.setColor(backgroundColor);
backgroundRect = new RectF(0, 0, width, height);
canvas.drawRoundRect(backgroundRect, 15, 15, mPaint);
mPaint.reset();
mPaint.setColor(progressColor);
checkProgress();
int xProgress = width * progress / max;
progressRect = new RectF(0, 0, xProgress, height);
canvas.drawRoundRect(progressRect, 15, 15, mPaint);
//triangle
mPaint.reset();
mPaint.setColor(backgroundColor);
Path path = new Path();
path.moveTo(xProgress, 0);
path.lineTo(0, height);
path.lineTo(xProgress - 50, 0);
path.lineTo(0, height);
path.lineTo(xProgress, 0);
path.close();
canvas.drawPath(path, mPaint);
}
建议取悦