2012-01-09 29 views
0

我在這個佈局問題,即:它不顯示任何孩子的ListView 之後和列表視圖中填補這一景象;它滾動,但沒有表現出任何其他孩子的LinearLayout不到風度顯示所有孩子的

我試圖用戶滾動型,但它與expandlist使問題

這是佈局的XML代碼:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/select_bg" 
android:orientation="vertical" > 

<TextView 
    android:id="@+id/Header" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/header_bg" 
    android:gravity="center" 
    android:paddingRight="50dip" 
    android:paddingTop="5dip" 
    android:text="@string/select" 
    android:textColor="#60240a" 
    android:textSize="18dip" 
    android:textStyle="bold" > 
</TextView> 

<ListView 
    android:id="@+id/listView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:cacheColorHint="@android:color/transparent" 
    android:divider="@drawable/line_divider" 
    android:dividerHeight="3dip" 
    android:listSelector="@android:color/transparent" > 
</ListView> 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="3dip" 
    android:src="@drawable/line_divider" /> 

<ExpandableListView 
    android:id="@+id/expandableList" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:cacheColorHint="@android:color/transparent" 
    android:childDivider="@drawable/line_divider" 
    android:divider="@drawable/line_divider" 
    android:dividerHeight="2dip" 
    android:listSelector="@android:color/transparent" 
    android:textColor="#60240a" > 
</ExpandableListView> 
</LinearLayout> 

謝謝

回答

0

當你在佈局使用ListView你必須添加此屬性android:layout_weight爲ListView。如果沒有設置此屬性,則無法獲得所有視圖。

0

給第一ListView一些恆定的高度。像

<ListView 
android:id="@+id/listView" 
android:layout_width="match_parent" 
android:layout_height="300dip" 
.... 
/> 

LinearLayout不會滾動時,其含量增加。並且您不能使用ScrollView作爲ListView的父項。

0

設置所有layout_height - 從根佈局fill_parent的直接孩子的屬性。 不是給每一個這些佈局一個屬性layout_weight的。 layout_weight的值是一個整數,這取決於它們在視圖中授予了多少空間。 例如兩個視圖:一個重量爲2,另一個重量爲1:重量1爲重量2的兩倍。 只需使用weight屬性稍微查找一下即可。

1

由於您的佈局是線性的,所以超出屏幕限制的任何視圖都不會顯示在屏幕上。是滾動視圖使列表或可擴展列表視圖的問題,因爲滾動視圖本身是可滾動的,它將消耗列表視圖和可擴展列表的滾動。要解決此問題,您必須重新排序或更改佈局以使其餘視圖可見

0

您已將listview的高度設置爲wrap_content,因此它將佔用屏幕中的所有空間,因此您將listview的高度固定同樣的東西適用於可擴展列表也給予了固定高度。

希望你得到這一切的最好

相關問題