添加圆角到一个图形页面 [英] Adding rounded corners to a mapview
问题描述
我想codeA简单MapActivity它使用了以下布局(只包含的MapView的时刻,因为我计划添加共享屏幕,在未来的一个ListView):
I'm trying to code a simple MapActivity which uses the following layout (only contains the mapview for the moment, as I plan to add share the screen with a ListView in the future) :
<?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为了具有圆角和中风
I have applied a simple shape to the mapview in order to have round corners and a stroke :
<?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>
我用下面的应用形态:
I use the following to apply the shape :
mapView.setBackgroundResource(R.layout.map);
问题是,它没有任何效果,我看不到我的圆角,也没有中风。
Problem is that it does not have any effect and I can't see my rounded corners, nor the stroke.
推荐答案
刚刚写的教程有圆角上一个MapView类,它的完成编程所以要很好地扩展到所有设备:
Just wrote a tutorial to have rounded corners on a MapView it's done programmatically so should scale well to all devices:
的http://www.anddev.org/novice-tutorials-f8/rounded-corners-map-view-t56908.html
一旦你添加自定义视图类,你可以只实例化一个圆形的图形页面,如下所示:
Once you have added the custom view class you can just instantiate a rounded mapview like so:
<com.blundell.tut.ui.widget.RoundedMapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
这篇关于添加圆角到一个图形页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!