在MapFragment下添加普通Layout

时间:2014-09-18 02:38:52

标签: java android google-maps-api-2

我正在尝试在MapFragment下面添加一个菜单面板,但这个东西总是出现在屏幕中间,就像浮动一样。我已经尝试了几种布局配置,但似乎没有用。

这是我的布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapActivity" >

    <fragment
        android:id="@+id/panel_map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:scrollbars="vertical" />

    <LinearLayout
        android:id="@+id/newmarker"
        android:layout_width="match_parent"
        android:layout_height="85dp"
        android:layout_gravity="center"
        android:background="#FFFFFFFF"
        android:gravity="center_horizontal"
        android:orientation="vertical"
        android:padding="4dp" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Nuevo marcadort"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <LinearLayout
            android:id="@+id/newmarker_options"
            android:layout_width="fill_parent"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:background="#FFFFFFFF"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/newmarker_save"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" />

            <Button
                android:id="@+id/newmarker_delete"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" />
        </LinearLayout>
    </LinearLayout>

</FrameLayout>

这是实际结果:

enter image description here

有什么想法吗?我做错了什么?

1 个答案:

答案 0 :(得分:1)

我刚刚添加了android:layout_gravity =&#34; bottom&#34;到新标记布局

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapActivity" >

    <fragment
        android:id="@+id/panel_map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:scrollbars="vertical" />

    <LinearLayout
        android:layout_gravity="bottom"
        android:id="@+id/newmarker"
        android:layout_width="match_parent"
        android:layout_height="85dp"
        android:background="#FFFFFFFF"
        android:gravity="center_horizontal"
        android:orientation="vertical"
        android:padding="4dp" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Nuevo marcadort"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <LinearLayout
            android:id="@+id/newmarker_options"
            android:layout_width="fill_parent"
            android:layout_height="48dp"
            android:layout_gravity="center"
            android:background="#FFFFFFFF"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/newmarker_save"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" />

            <Button
                android:id="@+id/newmarker_delete"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" />
        </LinearLayout>
    </LinearLayout>

</FrameLayout>
相关问题