【发布时间】:2015-07-28 11:08:03
【问题描述】:
对于画布上的一些画线,我想用颜色填充它。到目前为止,我所到之处如下:
int height = getMeasuredHeight();
int width = getMeasuredWidth();
canvas.drawRect(0,0,width, height, mBackgroundPaint);
for(ArrayList<PointF> arc : drawings) {
Iterator<PointF> iter = arc.iterator();
Path tempPath = new Path();
PointF p = iter.next();
tempPath.moveTo(p.x, p.y);
while (iter.hasNext()) {
PointF l = iter.next();
tempPath.quadTo(p.x, p.y, l.x, l.y);
p = l;
}
tempPath.lineTo(p.x, p.y);
canvas.drawPath(tempPath, paint);
}
在这段代码中,正在绘制 Arraylist 中的一些自定义绘制。它由tempPath 绘制。通过绘制一个填充的矩形来填充背景颜色。这里的问题是如果tempPath 被绘制并用颜色transparent 填充,则会显示背景颜色。我想从背景矩形中排除tempPath 中的点。
感谢您的帮助
【问题讨论】:
-
不知道你的问题是否正确,不就是
paint.setStyle(Style.FILL_AND_STROKE);吗? -
@ci_ 它填充了内部。我想在抽签之外填写
-
tempPath.toggleInverseFillType()那么? -
我觉得this answer可以帮你解决问题。