2011-08-25 26 views
10

質問からわかるように、mapViewには、ユーザーがボタンをプレゼンテーションするボタンを配置する必要があります。現在の位置でmapViewを更新します。 私はボタンを上に置く方法を知っていますが、地図上に置く方法は? サンプルコードがある方、またはガイダンスのヘルプがありがとうございました...MapViewにボタンを追加するにはどうすればいいですか?

答えて

29

あなたはRelativeLayoutを使用し、ボタンをMapViewの上に置いておきます。 Googleロゴに貼らないようにしてください。ここではサンプルXMLです:オーバーレイ項目の

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <com.google.android.maps.MapView android:id="@+id/google_maps" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:apiKey="@string/maps_key"/> 
    <Button android:id="@+id/googlemaps_select_location" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:text="Select"/> 
</RelativeLayout> 
+0

感謝の男..これは私が探していたものです...もう一度感謝します:DDD – Jovan

+0

ありがとう!これは私のために役立っています! – pandre