我在做一个页面,这个页面分三块,最上面是标题栏,最下面是负责翻页的框,这两个部分在屏幕中位置始终不变,如果中间再加一个listView怎么让listView填充剩余部分呢,如果listView过长就会把下面的框推出去了Androidlistview布局

解决方案 »

  1.   

    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" >    <TextView
            android:layout_width="fill_parent"
            android:layout_height="50dip"
            android:background="#606060"
            android:text="顶部" />    <ListView 
            android:id="@+id/list"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            />
        
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="50dip"
            android:background="#606060"
            android:text="底部" /></LinearLayout>RelativeLayout:<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >    <TextView
            android:id="@+id/tv_top"
            android:layout_width="fill_parent"
            android:layout_height="50dip"
            android:background="#606060"
            android:layout_alignParentTop="true"
            android:text="顶部" />    <ListView
            android:id="@+id/list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@+id/tv_top"
            android:layout_above="@+id/tv_bottom"
             />    <TextView
            android:id="@+id/tv_bottom"
            android:layout_alignParentBottom="true"
            android:layout_width="fill_parent"
            android:layout_height="50dip"
            android:background="#606060"
            android:text="底部" /></RelativeLayout>
      

  2.   

    android:layout_weight="1" 是关键。
      

  3.   


    楼上的,哈哈,上面还有个相对布局, 哪来的 weight,开始也差点被楼主忽悠了,哈哈
      

  4.   

    谢谢 zyxel60b的回答 问题解决了