如何设置圆角MapView小部件

时间:2018-09-23 12:46:03

标签: android android-mapview

如何设置圆角MapView小部件?

他是我的MapView

<com.google.android.gms.maps.MapView
                android:id="@+id/map_view"
                android:layout_width="match_parent"
                android:layout_height="260dp"
                app:liteMode="true"
                app:mapType="normal" />

谢谢

2 个答案:

答案 0 :(得分:1)

您可以尝试使用Cardview作为查看父对象

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="260dp"
    android:layout_gravity="center_horizontal|center_vertical"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="20dp"
    app:cardCornerRadius="20dp"
    app:cardElevation="0dp">

    <com.google.android.gms.maps.MapView
                android:id="@+id/map_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:liteMode="true"
                app:mapType="normal" />
</android.support.v7.widget.CardView>

答案 1 :(得分:1)

Ref:Adding rounded corners to a mapview

  

rectangle_rounded_corners.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
    <solid android:color="@android:color/transparent" />
    <stroke android:width="10dp" android:color="@color/color_gray5_eeeeee" />
    <corners android:radius="10px" />
</shape>

使用线性布局和具有与可绘制笔触宽度相同大小的边距,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rectangle_rounded_corners"
android:orientation="vertical">

<com.google.android.gms.maps.MapView
    android:id="@+id/map_details_map_view"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="10dp"
    android:clickable="true"
    android:enabled="true" />
</LinearLayout>
相关问题