【问题标题】:Image with Buttons - just above the Google Map带按钮的图片 - 位于 Google 地图上方
【发布时间】:2012-04-16 13:14:05
【问题描述】:

我想在“我的地图”上方添加一张图片,上面有 2 个按钮。我怎样才能做到这一点? 这就是我想在 Android 中实现的目标。

【问题讨论】:

  • 你的问题不清楚..你想要什么?你想在哪里添加图片??
  • @ top ---> 在图片中--Overview(Overview 是图像,edit 和 start 是按钮),我想在这个图像上添加按钮。

标签: android image map android-relativelayout


【解决方案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"

    />

【讨论】:

    【解决方案2】:

    试试这个代码。它将使用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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-26
      • 1970-01-01
      • 2014-07-16
      • 1970-01-01
      • 2017-12-29
      • 1970-01-01
      相关资源
      最近更新 更多