添加圆角到一个图形页面 [英] Adding rounded corners to a mapview

查看:194
本文介绍了添加圆角到一个图形页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆