2012-04-16 14 views
-1

我想添加一個圖像,位於我的地圖上方,上面有2個按鈕。我怎樣才能做到這一點? 這是我想在Android中實現的。 http://www.machinesthatgobing.com/images/skyhook-iphone-apple.jpg帶按鈕的圖像 - 正好位於Google地圖上

+0

你的問題不清楚..你想要什麼?你想添加圖像的地方? – 2012-04-16 13:24:43

+0

@頂部--->在圖片 - 概述(概述是圖片和編輯並開始是按鈕),我想在此圖片上添加按鈕。 – 2012-04-16 13:28:38

回答

1

檢查此鏈接一個MapView按鈕:

http://android-er.blogspot.in/2011/07/draw-on-custom-view-over-mapview.html

或者

您可以通過添加一個標題欄/視圖像這樣實現這一目標,使用該圖像作爲標題視圖的背景:

<RelativeLayout 
    android:id="@+id/headerlayout" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:background="drawable_image/color(Whatever u want)" 
    > 

    <Button android:id="@+id/one" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" android:text="one"> 
    </Button> 

    <Button android:id="@+id/two" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:layout_alignParentTop="true" 
     android:layout_alignParentRight="true" android:text="two"> 
    </Button> 
</RelativeLayout> 

<MapViewActivity 
    xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mapview" 
    android:layout_width="wrap_content" android:layout_height="wrap_content" 
    android:clickable="true" android:apiKey="your map key" 
    android:layout_below="@+id/headerlayout" 

    /> 
+0

謝謝,讓我試試。 – 2012-04-16 14:25:40

0

試試看看這個代碼。這將放置在使用RelativeLayout的

<?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 
     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="your_id" /> 
    <Button android:layout_below="@+id/mapview" 
     android:text="@+id/Button03" 
     android:id="@+id/Button01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentBottom="true"/> 
    <Button android:layout_below="@+id/mapview" 
     android:text="@+id/Button02" 
     android:id="@+id/Button02" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true"/> 
    <Button android:text="@+id/Button03" 
     android:id="@+id/Button03" 
     android:layout_width="wrap_content" 
     android:layout_toLeftOf="@+id/mapview" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentBottom="true"/> 
</RelativeLayout>