代码之家  ›  专栏  ›  技术社区  ›  Романыч

如何设置圆角地图视图小部件

  •  0
  • Романыч  · 技术社区  · 6 年前

    如何设置圆角地图视图小部件?

    他的是我的地图

    <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 回复  |  直到 6 年前
        1
  •  4
  •   Hazem Ashraf    6 年前

    您可以尝试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>
    
        2
  •  2
  •   Ashvin solanki    6 年前

    裁判: Adding rounded corners to a mapview

    <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>