I would like to draw a circle overlay in my android app, which I can ofcourse easily do and add a color to it as well.
But what I would really like to do is to keep the circle transparent and shade the outside of the circle (the rest of the world) with a light gray color.
I tried to add the circle as a path, shade the world and clip the circle out, but i get a bounding box around the circle on my device (although it looks fine on the emulator).
Any help appreciated. Below is a code snippet:
public void draw(Canvas canvas, MapView mapView, boolean shadow) { super.draw(canvas, mapView, shadow);
Projection projection = mapView.getProjection();
Point pt = new Point();
GeoPoint geo = new GeoPoint((int) (mLat * 1e6), (int) (mLon * 1e6));
projection.toPixels(geo, pt);
float circleRadius = projection.metersToEquatorPixels(mRadius)
* (1 / FloatMath.cos((float) Math.toRadians(mLat)));
Paint innerCirclePaint;
innerCirclePaint = new Paint();
innerCirclePaint.setColor(Color.TRANSPARENT);
innerCirclePaint.setAlpha(35);
innerCirclePaint.setAntiAlias(true);
innerCirclePaint.setStyle(Paint.Style.FILL);
Path path = new Path();
path.setFillType(Path.FillType.WINDING);
path.addCircle((float) pt.x, (float) pt.y, circleRadius, Path.Direction.CCW);canvas.drawPath(path, innerCirclePaint);
canvas.drawARGB(150, 0, 0, 0 );
canvas.clipPath(path);
}