我想画圆,用两种颜色着色。从 0 到 180 度的一种颜色,其余的第二种颜色。我有这样的事情:
private void drawCircle(Canvas c)
{
RectF oval = new RectF(20, 20, 100, 100);
c.drawArc(oval, 0, 180, false, getPaintWithColor(R.color.background));
c.drawArc(oval, 180, 360, false, getPaintWithColor(R.color.font_grey));
}
private Paint getPaintWithColor(int colorId){
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(4);
paint.setColor(getResources().getColor(colorId));
return paint;
}
但在此之后,弧线是单色的font_grey
。