Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中如何在google地图下方放置两个对齐的按钮_Android_Xml_Google Maps_Button - Fatal编程技术网

在Android中如何在google地图下方放置两个对齐的按钮

在Android中如何在google地图下方放置两个对齐的按钮,android,xml,google-maps,button,Android,Xml,Google Maps,Button,在Android中,如何在google地图下方放置两个按钮 我在下面使用此代码,它工作正常,但问题是地图也在按钮后面。我想设置按钮上方地图的高度。如何调整地图的大小并将地图底部放置在从中心均匀分布的两个按钮上方? 而不是android:layou alignTop=“@+id/map”在@+id/hello按钮中在片段中尝试android:layou=“@+id/map类型”。 注意,我必须删除片段中的类,并为其添加android:name <RelativeLayout xmlns:a

在Android中,如何在google地图下方放置两个按钮

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


而不是
android:layou alignTop=“@+id/map”
@+id/hello按钮中
在片段中尝试
android:layou=“@+id/map类型”
。 注意,我必须删除片段中的类,并为其添加android:name

<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
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:name="com.google.android.gms.maps.MapFragment"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_above="@+id/maptype"
    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_marginTop="346dp"
    android:text="Second"
    />
    <!--android:layout_alignTop="@+id/map"-->

编辑:完整XML的链接:

尝试将地图片段的布局高度设置为0dp,布局重量设置为1。 这对我很管用!以前,地图下面的一切都是看不见的。 此链接可能有用:

我尝试了你的代码,它强制关闭。。我似乎找不到使用class:class=“com.google.android.gms.maps.SupportMapFragment”时强制关闭的问题,因此,我删除了它并使用xmlns:android=“”android:name=“com.google.android.gms.maps.MapFragment”是的,它正是我想要的完美工作,但是你能提供一个包含3个按钮的示例代码吗?@IvanFuertes在一行relativelayout中包含3个按钮并不是很好。中间的按钮将比其他2个小。无论如何,您可以尝试使用以下代码:请标记为已回答:)
<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
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:name="com.google.android.gms.maps.MapFragment"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_above="@+id/maptype"
    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_marginTop="346dp"
    android:text="Second"
    />
    <!--android:layout_alignTop="@+id/map"-->