请求一个布局的写法。大概描述是这样的!总体是一个LinearLayout包含三个LinearLayout。
分三层。第一个LinearLayout要始终在顶部。
第二个LinearLayout要在中间。
      中间的这个LinearLayout肯定要包含其它布局,例如放一个ListView,能上下滑动。而不盖住第三个LinearLayout。
第三个LinearLayout要始终在底部。|------------------------|
|   button    button     |   <--第一个LinearLayout
|------------------------|
|                        |
|   只在此区域内可以     |   <--第二个LinearLayout
|   上下滑动,而不影响   |
|   其它布局             |
|------------------------|
|   button    button     |   <--第三个LinearLayout
|------------------------|大概描述是这样的请各位前辈指教!如果有其它好的思路方法也可以告知我。谢谢。以下是我写的,请指教<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/widget" 
android:layout_width="fill_parent" android:layout_height="fill_parent" 
android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/widget1" 
android:layout_width="wrap_content" android:layout_height="wrap_content" 
android:orientation="horizontal">
<Button android:id="@+id/btnSelect1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="查询" />
</LinearLayout>
<LinearLayout android:id="@+id/widget2" 
android:layout_width="wrap_content" android:layout_height="wrap_content" 
android:orientation="horizontal">
<Button android:id="@+id/btnSelect2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="查询" />
</LinearLayout>
<LinearLayout android:id="@+id/widget3" android:gravity="bottom" 
android:layout_width="wrap_content" android:layout_height="wrap_content" 
android:orientation="horizontal">
<Button android:id="@+id/btnSelect3" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="查询" />
</LinearLayout>
</LinearLayout>

解决方案 »

  1.   

    如果你要只在此区域内,上下滑动,而不影响其它布局的话,我建议要把中间布局固定大小!比如高多少,宽可以fill_parent
      

  2.   

    那上面的LinearLayout和下面的LinearLayout 怎么能固定在上部和下部那!
      

  3.   


    不用固定,而且布局中不建议用写死的值。你试一下,第二布局:android:layout_height="wrap_content" android:layout_weight="1.0"
    其他两个的高 android:layout_height="wrap_content"我就这样的做的。
      

  4.   

    如果你想把上面linearLayout和下面的LinearLayout分别固定在上部和下部,那你就在把整体的linearLayout换成RelativeLayout,然后在相应的上下linearlayout中分别设定那个对其上下的属性就ok了
      

  5.   


    这是一种方式,其实就像楼主那样也可以的。我直接用 LinearLayout 都没什么问题。
      

  6.   

    RelativeLayout 我用的很少!!刚刚学习!能否简单帮忙给我写个示例!
      

  7.   

    RelativeLayout 
    里面有相对父窗口的布局,只要在你子窗口里加上两个属性就可以相对于父窗口布局了
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
      

  8.   

    在你的xml基础上修改的:
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout android:id="@+id/widget" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        xmlns:android="http://schemas.android.com/apk/res/android">
        <LinearLayout android:id="@+id/layout_top" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"

            android:background="#ffff0000"
            >
        <Button android:id="@+id/btnSelect1" 
         android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="查询" />
        </LinearLayout>
        <LinearLayout android:id="@+id/layout_bottom" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"

            android:background="#ff00ff00"
            >
            <Button android:id="@+id/btnSelect2" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="查询" />
        </LinearLayout>
        <LinearLayout android:id="@+id/layout_center" 
         android:gravity="bottom" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
            android:layout_alignParentLeft="true"
            android:layout_above="@id/layout_bottom"
            android:layout_below="@id/layout_top"

            android:background="#ff0000ff"
            >
        <Button android:id="@+id/btnSelect3" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="查询" />
        </LinearLayout>
    </RelativeLayout>
    相对布局还是很好用的!
      

  9.   

    在三个</LinearLayout>中添加android:layout_weight="1"
      

  10.   

    我和楼主遇到的情况差不多!不过我是在中间的linearLayout中用的是ScrollView,会不会出现由于ScrollView中内容过长而出错?