如何在 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/