2012-07-10 87 views
0

我的佈局是一個滾動型與一些的TextView和其他控件和也是一個ExpandableListView。力ExpandableListView移動其他項目下

我想要做的是在展開ExpandableListView時,它下面的控件向下移動,並在摺疊後再次移動,所有控件向上移動,並且只有Group of Expendables變爲可見。

問題是,當使用wrap_content作爲expandView的高度時,擴展它沒有顯示任何內容,只是指示器(小箭頭)顯示它已擴展,並且明確使用某些數字時,例如。 200dp,expandView的最低項沒有顯示。 (因爲一起使用兩個滾動小部件)。

這裏是我的簡化的佈局。

<ScrollView 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:ignore="HardcodedText" > 
    <LinearLayout> 
     //some controls 
    </LinearLayout> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <ExpandableListView 
      android:id="@+id/lstDrugs" 
      android:layout_width="match_parent" 

//HERE is the point that wrap_content only shows the groups header 

      android:layout_height=**"wrap_content"** 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:divider="@drawable/dividergradient" 
      android:dividerHeight="2dp" > 
     </ExpandableListView> 

     <Button 
      android:id="@+id/btnAddDrug" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/lstDrugs" 
      android:text="Add" /> 
    </RelativeLayout> 
</LinearLayout> 

+1

你能先解決您發佈的XML。你有2個直接的子元素用於你的滾動視圖。也請解釋目前發生的事情。你的問題並不清楚。 – Fraggle 2012-07-10 14:16:47

+0

我剛剛解釋正在發生什麼問題。這是我的XML的重要組成部分,不是全部。 – mammadalius 2012-07-10 14:23:19

+0

好,感謝有點幫助。請將android:fillViewport =「true」添加到您的scrollView並查看是否有幫助。你可能仍然有問題。 ListViews和ExpandableList視圖也將滾動視圖,因此會在滾動視圖內嵌入這些視圖。 – Fraggle 2012-07-10 14:43:30

回答

1

我剛剛發現我的答案this線程。

的問題是使用內滾動型中列表。要處理它,你應該使用ScrollView以外的佈局(例如LinearLayout),並添加其他小部件,如標題頁腳的列表。這將啓用視圖的滾動和List的擴展。

相關問題