使用PathDashPathEffect绘制图像中的最后一行。我使用以下代码绘制此行。
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(color);
// mPaint.setAlpha(120);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(6.0f);
cornerpatheffect = new CornerPathEffect(10);
pathdashpath = new PathDashPathEffect(makePathDash(), 10, 3,
PathDashPathEffect.Style.MORPH);
patheffect = new ComposePathEffect(cornerpatheffect, pathdashpath);
mPaint.setPathEffect(pathdashpath);
private Path makePathDash() {
Path p = new Path();
p.moveTo(-6, 9/2);
p.lineTo(6,9/2);
p.lineTo(6,9/2-1);
p.lineTo(-6, 9/2-1);
p.close();
p.moveTo(-6, -(9/2));
p.lineTo(6,-(9/2));
p.lineTo(6, -(9/2-1));
p.lineTo(-6, -(9/2-1));
return p;
}
有没有办法增加两条线的笔划宽度。对于您的信息,setstrokewidth方法不适用于PathDashPathEffect。有人可以帮帮我吗?
答案 0 :(得分:0)
我不知道你是否还需要答案,
是的,你只需改变这样的坐标:
private Path makePathDash() {
Path p = new Path();
p.moveTo(-6, 9/2);
p.lineTo(6,9/2);
p.lineTo(6,9/2-2);
p.lineTo(-6, 9/2-2);
p.close();
p.moveTo(-6, -(9/2));
p.lineTo(6,-(9/2));
p.lineTo(6, -(9/2-2));
p.lineTo(-6, -(9/2-2));
return p;
}
并将(-2)更改为(-3)以使其更厚......