android - 如何在 Android 中的谷歌地图下方放置两个对齐的按钮

标签 android xml google-maps button

如何在 Android 中的谷歌地图下方放置两个按钮?

我在下面使用这段代码,它工作正常,但问题
是 map 也在按钮后面。我想在按钮上方设置 map 的高度。
我如何才能调整 map 的大小,并将 map 的底部平均
放置在从中心分布的两个按钮上方?

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" >

<fragment
  android:id="@+id/map"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_alignParentRight="true"
  android:layout_below="@+id/editText1"
  class="com.google.android.gms.maps.SupportMapFragment" />

<Button
  android:id="@+id/button1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignBottom="@+id/editText1"
  android:layout_alignParentRight="true"
  android:layout_alignParentTop="true"
  android:text="Button" />

<EditText
  android:id="@+id/editText1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignParentLeft="true"
  android:layout_alignParentTop="true"
  android:layout_toLeftOf="@+id/button1"
  android:ems="10" >
  <requestFocus />
  </EditText>

<Button
 android:id="@+id/maptype"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentBottom="true"
 android:layout_alignParentRight="true"
 android:layout_alignTop="@+id/hello"
 android:layout_toRightOf="@+id/view"
 android:text="First" />
<View
    android:id="@+id/view"
    android:layout_width="0dp"
    android:layout_height="1dp"
    android:layout_centerHorizontal="true" />
<Button
    android:id="@+id/hello"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignRight="@+id/view"
    android:layout_alignTop="@+id/map"
    android:layout_marginTop="346dp"
    android:text="Second" />
</RelativeLayout>

最佳答案

尝试将 map fragment 的 layout_height 设置为 0dp,将 layout_weight 设置为 1。 这对我来说很好!以前, map 下方的一切都是看不见的。 此链接可能有用: Create buttons below google map

关于android - 如何在 Android 中的谷歌地图下方放置两个对齐的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28183262/

相关文章:

javascript - Ruby 生成的 javascript 文件不会在页面刷新时更新

java - 在安卓模拟器中访问谷歌地图

javascript - IE 和 GMap API 2 包装器错误

Swift:拆分以逗号分隔的字符串,但如果逗号用单引号引起来则不会

android - Facebook 通过 android 应用程序共享 - 更改 "shared via <AppName>"的 url

android - 如何将水平回收 View 居中居中?

android - 单击android phonegap中的按钮时退出应用程序?

xml - 使用 XSL 合并和排序多个 XML 文件

c - 将大量 xml 文件转换为文本时出现段错误

Android Studio App only Debug模式