10

I have a MapView that I would like to clip to a circle drawable. MapView:

        <com.google.android.gms.maps.MapView
            android:id="@+id/map_view"
            android:layout_width="match_parent"
            android:layout_height="200dp">
        </com.google.android.gms.maps.MapView>

And here is the the circle drawable:

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <stroke android:color="#ffffff" android:width="100dp"></stroke>
    <solid android:color="@android:color/transparent"/>
</shape>

So with Lollipop, I can simply do a

mapView.setBackgroundResource(R.drawable.circle);
mapView.setClipToOutline(true);

Which clips the View into a circle. But this doesn't work below API 21. What is the equivalent way to do it with the support library for Jellybean and KitKat?

George Yang
  • 694
  • 6
  • 18

0 Answers0