Is there a way to implement rounded corners to a Mapfragment?

后端 未结 7 666
忘了有多久
忘了有多久 2020-11-30 09:10

I want to give the map a nice looking rounded corners as the two boxes below it have. I can\'t do it with the map fragment it self because there is not a background property

相关标签:
7条回答
  • 2020-11-30 10:07

    I haven't tried this, but I'd put a view with rounded corners and a transparent middle on top of the mapView / mapFragment.

    That is, put the mapFragment and the rounded corner view in a FrameLayout with both filling the FrameLayout, then make the middle of the rounded corner view transparent.

    For further clarification, you could do it in a layout as follows:-

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    
    <fragment
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/mapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.MapFragment" />
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/rounded_background"
        android:orientation="vertical" >
    </LinearLayout>
    
    </FrameLayout>
    

    The rounded_background is a 9-patch with rounded corners and a transparent middle. E.g.

    rounded_background.9.png

    Hope that helps,

    Ryan

    0 讨论(0)
提交回复
热议问题