2011-09-19 109 views
1

我想知道是否有一种方法可以扩展覆盖图,以使它们能够在地图上的特定位置上显示视图。如何在地图上叠加视图?

如果可能的话,你能帮助我的代码段或链接我上网看了一下,但无法找到任何东西,确实有帮助。

回答

1

您可以像这样创建RelativeLayout。

这里是例子。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <com.google.android.maps.MapView 
     xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mapview" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:clickable="true" android:apiKey="you key" /> 

    <ImageView android:id="@+id/cur_loc" android:layout_width="wrap_content" 
      android:layout_height="wrap_content" android:src="@drawable/cur_loc" 
      android:visibility="gone" android:padding="0dip" 
      android:layout_margin="0dip" android:background="#ffffff" /> 

    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/track_dist_linear" 
     android:background="#ffffff" android:orientation="vertical"> 
     <TextView android:id="@+id/txt_msg" android:layout_width="fill_parent" android:layout_height="wrap_content" 
     android:textColor="#000000" android:text="Distance 0 km"/> 
     <TextView android:id="@+id/speed_msg" android:layout_width="fill_parent" android:layout_height="wrap_content" 
     android:textColor="#000000" android:text="Speed 0 kmph \ntime 0 sec"/> 
    </LinearLayout> 
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/track_dist_linear"> 
     <Button android:id="@+id/track_btn" android:text="Start" android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
     <Button android:id="@+id/show_track_btn" android:text="Show" android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
    </LinearLayout> 
</RelativeLayout> 
+0

先谢谢您的回复,可能是我还不够清楚:我不想添加overlayitem (标记),但一个视图(按钮,文本视图..)并将它们放置在地图上,这样它们就会移动,如果我为mapview设置动画 –

+0

检查更新后。顺便说一下,我认为不需要使用叠加添加按钮或视图,您可以使用与地图上的标记相同的叠加和显示按钮图像,以便它可以在地图上移动 – Pratik