android - Custom view draw circle produces elipse -


i have custom view , i'm trying draw circle in middle of view. code produces elipse:

paint p = new paint(); p.setstyle(style.stroke); p.setcolor(color.green); p.setstrokewidth(0.02f);  mcanvas.drawcircle(0.5f, 0.5f, 0.2f, p); 

problem

the view width , height same darker round rectangle.

after few tries, figured out it's because width , height of canvas not equal. had scale canvas same width/height. code if encounters same problem:

mcanvas.save(); mcanvas.scale(1f, ratio); //ratio between width , height mcanvas.drawcircle(0.5f, 0.5f/ratio, 0.2f, p); mcanvas.restore(); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -