Android线性布局隐藏

Android线性布局隐藏,android,Android,我认为这是一个相当简单的问题,但我没有得到我想要的方式。 我想在Android上做一个线性布局,有3个区域 顶部区域应具有固定的高度、填充和宽度。 第二个,在第一个下面,应该使用所有可用的房间,填充父宽度。 第三个,在第二个之下,应该有固定的高度,填充宽度 以下是我得到的: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/re

我认为这是一个相当简单的问题,但我没有得到我想要的方式。 我想在Android上做一个线性布局,有3个区域

顶部区域应具有固定的高度、填充和宽度。 第二个,在第一个下面,应该使用所有可用的房间,填充父宽度。 第三个,在第二个之下,应该有固定的高度,填充宽度

以下是我得到的:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:gravity="bottom"
  android:background="#ff63a920">
   <LinearLayout
android:id="@+id/top_bar"
android:layout_width="fill_parent"
android:layout_height="32dp"
>
</LinearLayout>
  <com.google.android.maps.MapView android:id="@+id/mymapView"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"


        />
 <LinearLayout
android:id="@+id/bottombar"
android:layout_width="fill_parent"
android:layout_height="32dp"
>
</LinearLayout>
</LinearLayout>

问题是,中间的MavVIEW太大,所以它推导出了TopBar。


我希望你能帮助我。

多亏了塞巴斯蒂安,这就是成功的原因:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:gravity="bottom"
  android:background="#ff63a920">
   <LinearLayout
android:id="@+id/top_bar"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_weight="0"
>
</LinearLayout>
  <com.google.android.maps.MapView android:id="@+id/mymapView"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:layout_weight="1"

        />
 <LinearLayout
android:id="@+id/bottombar"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_weight="0"
>
</LinearLayout>
</LinearLayout>

多亏了塞巴斯蒂安,这就是成功的秘诀:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:gravity="bottom"
  android:background="#ff63a920">
   <LinearLayout
android:id="@+id/top_bar"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_weight="0"
>
</LinearLayout>
  <com.google.android.maps.MapView android:id="@+id/mymapView"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:layout_weight="1"

        />
 <LinearLayout
android:id="@+id/bottombar"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_weight="0"
>
</LinearLayout>
</LinearLayout>

有一个叫做DroidDraw的软件。(免费软件)使用它,它将自动为您生成XML代码


希望对你有所帮助有一个叫做DroidDraw的软件。(免费软件)使用它,它将自动为您生成XML代码


希望这会有所帮助。我想知道是否将顶级容器设置为相对化是一个更好的主意。您尝试过
layout\u-weight
设置吗?我说的很简单:layout\u-weight=0表示顶部和底部,layout\u-weight=1表示地图视图。我想知道是否将顶级容器设置为相对化是一个更好的主意。您尝试过吗
layout\u-weight
settings?我说的很简单:layout\u-weight=0表示顶部和底部,=1表示mapview。