为什么drawPath不工作?

Rob*_*bin 2 android draw android-canvas

我有drawpath的代码,没有任何显示,我无法弄清楚为什么.

//i move the path's starting point somewhere up here to a point.
//get center x and y are the centers of a picture. it works when i
//do drawline and store the different starting points 
//but i want it to look continuous not like a lot of different
//lines

path.lineTo(a.getCenterX(), a.getCenterY());
path.moveTo(a.getCenterX(), a.getCenterY());


p.setStrokeWidth(50);
p.setColor(Color.BLACK);
canvas.drawPath(path,p);
Run Code Online (Sandbox Code Playgroud)

drawpath图像

提前致谢

Bre*_*ust 10

新的Paint实例仅填充路径.

描边路径,请设置"绘制"样式:

paint.setStyle(Paint.Style.STROKE);
Run Code Online (Sandbox Code Playgroud)

如果您正在绘制的背景是黑色,请更改颜色,以便您可以看到颜色:

paint.setColor(Color.RED);   // something other than the background color
Run Code Online (Sandbox Code Playgroud)

可选的:

paint.setStrokeWidth(10);  // makes the line thicker
Run Code Online (Sandbox Code Playgroud)


Rob*_*bin 6

  我不得不将它添加到绘画中以使其工作.不知道为什么.

mPaint.setDither(true);
mPaint.setColor(0xFFFFFF00);
mPaint.setStyle(Paint.Style.STROKE);    
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(3);
Run Code Online (Sandbox Code Playgroud)