Android MapView - 如何将附加控件附加到所需位置的MapView
问题描述:
我需要将其他图像按钮“我的当前位置”放置到MapView的右上角。任何想法如何做到这一点?Android MapView - 如何将附加控件附加到所需位置的MapView
提出通用问题:
1)根据MapView文档,可以将附加视图对象附加到MapView。这个怎么做?
2)如何将这些附加控件放置在MapView的特定位置?
答
下面的示例将在MapView的一个按钮,只需复制粘贴,然后移动按钮,你喜欢它:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_main"
android:orientation="vertical"
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="fill_parent"
android:clickable="true"
android:apiKey="0y6Hyjz6Kxo-NOV_9KHYF7-ECYeGt99xeyVU3IQ"/>
<Button
android:id="@+id/select_3"
android:layout_centerHorizontal="true"
android:layout_marginTop="13dp"
android:text="Center on Pickup Location"
style="@style/BasicButton"
android:layout_height = "40dp"
android:layout_width = "280dp"
android:onClick="selfSelectCenterLocation">
</Button>
</RelativeLayout>