android - 向 map View 添加圆角

标签 android android-mapview rounded-corners

我正在尝试编写一个使用以下布局的简单 MapActivity(目前仅包含 map View ,因为我计划在将来添加与 ListView 共享屏幕):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="200dip"
    android:enabled="true"
    android:clickable="true"
    android:apiKey="mykey"
    android:layout_alignParentBottom="true" />
</RelativeLayout>

我已将一个简单的形状应用于 mapview,以便具有圆角和描边:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <corners android:bottomRightRadius="10dp"
              android:bottomLeftRadius="10dp" 
              android:topLeftRadius="10dp"
              android:topRightRadius="10dp"/> 
     <stroke  android:width="3dp"
              android:color="@color/bordure_tables" />
</shape>

我使用以下方法来应用形状:

mapView.setBackgroundResource(R.layout.map);

问题是它没有任何效果,我看不到我的圆角,也看不到笔划。

最佳答案

刚刚编写了一个在 MapView 上设置圆角的教程,它是通过编程完成的,因此应该可以很好地扩展到所有设备:

http://www.anddev.org/novice-tutorials-f8/rounded-corners-map-view-t56908.html

一旦你添加了自定义 View 类,你就可以像这样实例化一个圆形的 map View :

<com.blundell.tut.ui.widget.RoundedMapView
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"/>

关于android - 向 map View 添加圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5211731/

相关文章:

android - 在 Android 中关闭飞行模式

Android 在谷歌地图上延迟添加地理点

swift - 如何使用 Swift 3 创建不带交互式剪切区域的圆形标签/按钮

Android-Maps-Extensions 异步加载标记图像

javascript - 大约 2 分钟后,Webaudio 声音在 Chrome for Android 上停止

android - 为什么滚动 ListView 会大量增加内存使用量?

Swift 3.0 为 MapView 设置注释图钉颜色

android - MapView 非常慢, map 上有 1000 个覆盖项,即使只有 2 个可见项

objective-c - IOS:创建带有圆角的 UIImage 或 UIImageView

swift - 如何删除带有圆形/弧形路径的阴影 UIView 中的弧形边框?