문제

when draw a line in canvas using path i getting little glitch as in picture below...i'm new to android development..i know i'm making some silly mistake i don't know what it is...if anyone hav an idea help me..thanks

enter image description here

enter image description here

my path code is

 path.moveTo((this.pos/2),0);
              path.lineTo((this.pos/2),25);
              path.lineTo(this.pos,25);
              path.close();
              canvas.drawPath(path, ppaint);
도움이 되었습니까?

해결책

You can just use canvas.drawLine(this.pos/2, 25, this.pos, 25, ppaint). drawPath() is working as expected in your code ;)

다른 팁

You could try

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top