-1
我一直在试图绘制一个圆弧顶部填充颜色的圆弧,并删除customview矩形中圆弧的底部部分。我经历了很多stackoverflow问题,但它不起作用。画布中的白色区域需要从下面的截图中移除。这里显示了customview的代码。请帮我解决这个问题。由于如何从正方形customview android中删除部分画布?
代码:
@Override
protected void onDraw(Canvas canvas) {
float size = Math.min(getWidth(), getWidth());
RectF rectRectF = new RectF(0, 0, getWidth(), getHeight());
Path rectPath = new Path();
rectPath.addRect(rectRectF, Path.Direction.CCW);
Paint bgPaint = new Paint();
bgPaint.setColor(Color.RED);
canvas.drawPath(rectPath, bgPaint);
RectF rectF = new RectF(0, 0, 2 * getWidth(), 2 * getWidth());
Paint transparentPaint = new Paint();
transparentPaint.setColor(Color.WHITE);
transparentPaint.setAntiAlias(true);
canvas.drawArc(rectF, 180, 90, true, transparentPaint);
}
我已经使用过这段代码,但是当我设置矩形画布的背景颜色时,这段代码给出了圆弧的透明bg。但背景颜色来到前景,我不想在画布上做 –