Search code examples
androidandroid-canvas

line gets thick when scaling


I draw a line in Android canvas with the thickness of 1 (paint.setStrokeWidth(1)). When scaling the canvas with canvas.scale(2,2), then the line gets thicker. How can I draw the line only one pixel thick, even if I am scaling in (e.g. zooming in)?


Solution

  • Set the width for stroking. Pass 0 to stroke in hairline mode. Hairlines always draws a single pixel independent of the canva's matrix.