我正在尝试编写一个使用以下布局的简单 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/