布局问题:如何把东西顶部和底部? [英] Layout problem: how to place something on top and bottom?

查看:112
本文介绍了布局问题:如何把东西顶部和底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个布局,在顶部和底部的水平LinearLayout中(S),一个ListView填补中间。

I want create a layout, with a horizontal LinearLayout(s) on top and bottom, a ListView fill in middle.

我如何定义main.xml中。

How can I define the main.xml.

我试图创建与顶部水平的LinearLayout布局,TextView的底部,一个ListView填写中间;就可以了。但经过我修改了底层的TextView到的LinearLayout,底部的LinearLayout消失。

I tried to create a layout with horizontal LinearLayout on top, TextView on bottom, a ListView fill in middle; is ok. But after I modified the bottom TextView to LinearLayout, the bottom LinearLayout disappear.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    >
    <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal"
        >
        <TextView 
            android:textSize="12px" 
            android:text="something here" 
            android:layout_width="50px" 
            android:layout_height="wrap_content"
            /> 
        <TextView 
            android:textSize="12px" 
            android:text="something here" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            />
    </LinearLayout> 

    <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:gravity="bottom" 
        >
        <ListView 
            android:id="@+id/listbody" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            />
        <LinearLayout 
            android:orientation="horizontal" 
            android:layout_height="wrap_content" 
            android:layout_width="fill_parent" 
            > 
            <TextView 
                android:layout_height="wrap_content" 
                android:layout_width="0dip" 
                android:layout_weight="1" 
                android:textSize="12px" 
                android:text="50%" 
                /> 
            <TextView 
                android:layout_height="wrap_content" 
                android:layout_width="0dip" 
                android:layout_weight="1" 
                android:textSize="12px" 
                android:text="50%" 
                /> 
        </LinearLayout> 
    </LinearLayout> 
</LinearLayout>

任何人都可以告诉指教? 请大家帮帮忙。

Anybody can tell advise? Please help.

推荐答案

尝试包含一整套的RelativeLayout的:

Try containing the whole set in a RelativeLayout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/top_linear_layout_id"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" >
    </LinearLayout>

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/bottom_linear_layout_id"
        android:layout_below="@id/top_linear_layout_id" />

    <LinearLayout
        android:id="@+id/bottom_linear_layout_id"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >
    </LinearLayout>
</RelativeLayout>

编辑与大小的东西。

Edited with sizing stuff.

这篇关于布局问题:如何把东西顶部和底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆