在画布上,我绘制了彼此覆盖的数字以获得我想要的结果。它们的透明度为128,覆盖区域的颜色为多个。我需要一种颜色的整体图形。如何解决?
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
paint.setColor(Color.GREEN);
Path path = new Path();
path.moveTo(margin,0);
path.lineTo(middleWidth+pieceWidth,0);
path.lineTo(middleWidth-pieceWidth,height);
path.lineTo(margin, height);
path.lineTo(margin, 0);
Path path1 = new Path();
path1.moveTo(middleWidth+pieceWidth+interval,0);
path1.lineTo(middleWidth-pieceWidth+interval,height);
path1.lineTo(width-margin,height);
path1.lineTo(width-margin,0);
path1.lineTo(middleWidth+pieceWidth+interval,0);
RectF rect = new RectF();
rect.set(0,0,middleWidth-pieceWidth,height);
RectF rect1 = new RectF();
rect1.set(middleWidth+pieceWidth,0,width,height);
paint.setStyle(Paint.Style.FILL);
paint.setColor(leftColor);
paint.setAlpha(128);
canvas.drawPath(path, paint);
paint.setColor(rightColor);
paint.setAlpha(128);
canvas.drawPath(path1, paint);
paint.setAlpha(128);
paint.setStyle(Paint.Style.FILL);
canvas.drawRoundRect(rect, corners, corners, paint);
canvas.drawRoundRect(rect1, corners, corners, paint);
}
结果是: