Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well I tried the above code and it works fine. Interesting thing is if I make <code>minSdkVersion</code> to 14 it draws something but the results are not right. Even though I am running on ICS device, changing <code>minSdkVersion</code> to 13 works fine. I tried disabling hardware acceleration (as @John Willis said) with <code>minSdkVersion</code> set to 14 it works. Here is the summary in short:</p> <ul> <li>If you set <code>minSdkVersion</code> to 14 then HW acceleration is on by default.</li> <li>If you set <code>minSdkVersion</code> to 13 then HW acceleration is off by default.</li> </ul> <p>soln 1: switch off hardware either manually or my <code>minSdkVersion</code> soln 2: scale urself by calculating scale factor like </p> <pre><code>float scale = (float) getWidth(); mscale.setScale(scale); ..... canvas.drawCircle(mscale.getX(0.5f), mscale.getY(0.5f), mscale.getUniScaled(0.25f), basicpaint); </code></pre> <p>Class for scale</p> <pre><code> class MyScale { float scaleX; float scaleY; float uniformScale; public void setScale(float scale) { scaleX = scale; scaleY = scale; uniformScale = scale; } private float getX(float x) { return x * scaleX; } private float getY(float y) { return y * scaleY; } private float getUniScaled(float value) { return value * uniformScale; } } </code></pre> <p>Here is the image for api level 10.</p> <p><img src="https://i.stack.imgur.com/7sas6.png" alt="Circle"></p> <p>So the only problem I can think of is with <code>getWidth</code>. Check your layout or code which is setting this width. It could be that for some reason this with is too low. For your code to work, the width cannot be less than 4 (preferable 5 as there is floating point calculation). As <code>drawCircle</code> cannot draw smaller than <a href="http://developer.android.com/reference/android/graphics/Canvas.html#drawCircle%28float,%20float,%20float,%20android.graphics.Paint%29" rel="nofollow noreferrer">1 pixel</a>.</p> <p><strong>Edit 1</strong></p> <p>Running on api level 14 works fine.</p> <p><img src="https://i.stack.imgur.com/WGsnp.png" alt="Circle with api level 14"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload