ListView 的高度设为0dp,然后设置 layout_weight="1",通过权重设置高度

解决方案 »

  1.   

    你可以看看关于线性布局的 layout_weight, 这样好一点,设置权重之后,他会将除了设定了高度的控件所占据的所有剩余高度按照权重平均分配,是通常用来做适配的利器
      

  2.   

    不行的,把ListView的高度设成0dp直接就报错了
      

  3.   

     <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:paddingBottom="8dp" >        <ListView
            android:id="@+id/companyListView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:divider="@drawable/divier"
            android:listSelector="#00000000" />
            <!--<include layout="@layout/my_company_item_layout" />-->
        </LinearLayout>
    好吧,发现了你的 ListView 外面包了一层 LinearLayout, 这一层去掉吧,就 ok 了