You can just use canvas.drawLine(this.pos/2, 25, this.pos, 25, ppaint)
. drawPath() is working as expected in your code ;)
canvas line glitch
-
31-03-2022 - |
Pergunta
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
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);
Solução
Outras dicas
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();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow