Question

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);
Was it helpful?

Solution

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

OTHER TIPS

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top