2

当使用路径在画布上画一条线时,我遇到了一些小故障,如下图所示...我是 android 开发新手..我知道我犯了一些愚蠢的错误,我不知道它是什么...如果有人有一个想法帮助我..谢谢

在此处输入图像描述

在此处输入图像描述

我的路径代码是

 path.moveTo((this.pos/2),0);
              path.lineTo((this.pos/2),25);
              path.lineTo(this.pos,25);
              path.close();
              canvas.drawPath(path, ppaint);
4

2 回答 2

1

你可以只使用canvas.drawLine(this.pos/2, 25, this.pos, 25, ppaint). drawPath() 在您的代码中按预期工作;)

于 2013-04-01T13:51:19.313 回答
0

你可以试试

ctx.beginPath();
ctx.moveTo((this.pos/2),0);
ctx.lineTo((this.pos/2),25);
ctx.lineTo(this.pos,25);
ctx.closePath();
ctx.strokeStyle = "Red";//border color here
ctx.stroke();
ctx.fillStyle = "blue";//fill color here
ctx.fill();
于 2016-03-31T19:04:00.747 回答