I am trying to show a MapView as a circle on Android just like that:
protected void onDraw(Canvas canvas) {
Path path = new Path();
path.addCircle(400,200,100,Direction.CW);
canvas.clipPath(path);
super.onDraw(canvas);
}
Unfortunately the MapView (v2: com.google.android.gms.maps.MapView) component seems to ignore that and instead just taking the bounds/rect of that circle to draw the map 🙁
I’ve been searching the web for a while now, not finding a nice solution for that.
Is this even possible? (The Blundell solution is not working for me because I want the background to be visible around the map)
Thanks!
Android supports a hardware acceleration since API level 11. The problem is that not all drawing operations are supported when hardware acceleration is turned on. And
Canvas.clipPathis one of them. Complete list of unsupported operations can be found hereYou can try to implement what you want without using
clipPathor just disable hardware acceleration.To disable hardware acceleration on application level make sure you have
targetSdkVersion11 or higher and usehardwareAcceleratedtag in theAndroidManifest:You can disable hardware acceleration only for the particular view using the following method.
Note that you have to use
TargetApiannotation and check if device android version isHoneycombor higher, otherwiseEclipsemay produce an error.If code from your question isn’t working try to replace it with this: