2012-07-10 86 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的扩展。

相关问题