带按钮的图像 - 就在谷歌地图上方

时间:2012-04-16 13:14:06

标签: android image map relativelayout

我想在我的地图上方添加一个图像,上面有2个按钮。我怎样才能做到这一点? 这是我想要在Android中实现的。 http://www.machinesthatgobing.com/images/skyhook-iphone-apple.jpg

2 个答案:

答案 0 :(得分:1)

检查此链接:

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"

    />

答案 1 :(得分:0)

试试这段代码。它将使用RelativeLayout

在mapview上放置按钮
<?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>
相关问题