Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding rounded corners to a mapview

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>

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.

like image 766
Adam Dulson Avatar asked Sep 05 '26 03:09

Adam Dulson


2 Answers

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"/>
like image 173
Blundell Avatar answered Sep 07 '26 17:09

Blundell


Have you tried assigning it a padding?

<padding 
     android:left="2dp" 
     android:top="2dp" 
     android:right="2dp" 
     android:bottom="2dp" /> 

So your strokes and radius should be visible.

like image 41
Gabo Avatar answered Sep 07 '26 17:09

Gabo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!