Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: canvas.drawCircle has an ellipse inside of it?
    primarykey
    data
    text
    <p>I am attempting to draw a custom Drawable overlay on a MapView. I use a custom class that extends Drawable to draw the circle on a canvas. Then I pass a radius variable to it and add it to an ItemizedOverlay which gets applied to the MapView.</p> <p>So far it is working out pretty well, but for some reason, the canvas.drawCircle method is drawing a transparent circle with what looks like an ellipse inside of it, and I can't, for the life of me, figure out what is causing it. I do want the circle to be transparent, but I don't want this ellipse thing inside of it.</p> <p>Here is the custom Drawable class:</p> <pre><code>import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.drawable.Drawable; public class PileDrawable extends Drawable { private static final Paint paint = new Paint(); int rad; public PileDrawable(int radius) { paint.setARGB(100, 0, 255, 0); paint.setAntiAlias(false); paint.setStyle(Paint.Style.FILL); rad=radius; } @Override public void draw(Canvas canvas) { canvas.drawCircle(0, 0, rad, paint); } @Override public int getOpacity() { return 0; } @Override public void setAlpha(int alpha) { } @Override public void setColorFilter(ColorFilter cf) { } } </code></pre> <p>This is kind of what it looks like, ignore my lack of MS paint skills...</p> <p><a href="http://img222.imageshack.us/img222/4356/circleellipse.png" rel="nofollow">http://img222.imageshack.us/img222/4356/circleellipse.png</a></p> <p>I have a lingering feeling that the problem occurs when I apply the bounds to the Drawable.</p> <pre><code>PileDrawable pd = new PileDrawable((int)(mapView.getProjection().metersToEquatorPixels(Radius) * (1/ Math.cos(Math.toRadians(point.getLatitudeE6()))))); pd.setBounds(0,0,pd.getIntrinsicWidth(),pd.getIntrinsicHeight()); //HERE? </code></pre> <p>So, any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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