Java – how to draw a border around MapView
•
Java
I try to draw margins around MapView when I click a button
So that's what I've tried. It doesn't work MapView is located in a relative layout
LayoutInflater inflater = getLayoutInflater(); LinearLayout mView = (LinearLayout) inflater.inflate( R.layout.map_view_create_ps,mapView,false); GeoPoint viewLoc = mapView.getMapCenter(); MapView.LayoutParams params = new MapView.LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT,viewLoc,MapView.LayoutParams.BOTTOM_CENTER); mView.setLayoutParams(params); mapView.addView(mView); mView.setVisibility(View.VISIBLE);
The above content is called when the button is clicked
My create_ ps_ That's the layout
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/transparent"> <LinearLayout android:layout_width="fill_parent" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_height="fill_parent" android:background="@drawable/rounded_boarder"></LinearLayout> </LinearLayout>
The paintable background is like this
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"> <solid android:color="@color/translucent_black" /> <corners android:bottomRighTradius="30dp" android:bottomLefTradius="30dp" android:topLefTradius="30dp" android:topRighTradius="30dp" /> <stroke android:width="2dip" android:color="#FFB600"/> </shape>
This doesn't work, but when you select the button, can you point out the correct direction of how I draw the border around the MapView?
Solution
Place MapView in a relativelayout and set the padding property of relativelayout as follows:
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1" android:background="#444" android:padding="2dp"> <com.google.android.maps.MapView android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="YOUR-MAP-KEY" android:clickable="true"/> </RelativeLayout>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码