我已经按照this教程使用了可扩展列表视图。
这是我想要实现的目标:
[第1组]
[第2组]
[第3组] ---固定高度
..........
.........
.........
[第4组] - 3个项目的可扩展列表
[第5组] - 3个项目的可扩展列表
上面的整个布局不应该滚动,我的意思是只有第三组才能看到所有组都应该可见,并且启用滚动时应该可以看到几个孩子。
任何人都可以帮我吗?
答案 0 :(得分:1)
所以我猜你的意思是你想要的是点击每个组。该组已扩展,其余组仍然可见。这意味着孩子们会挤进去#34;各组之间。
第一种方法是在可扩展列表视图中添加固定大小的scrollview(或listview)作为每个组的唯一子项。虽然从我自己的经验来看,我知道嵌套的滚动容器工作效果很差,所以我会做的就是:
不要使用可扩展的列表视图,而是使用五个视图,它们看起来就像可扩展列表视图中的组行,以及单击一个组时。您在单击的行下方添加固定大小的scrollview / listview。你认为这对你有用吗?
这样做的一个例子就像我在下面显示的代码一样。使用您喜欢的任何类型的视图/按钮/文本视图作为组标题。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/group_header1"
android:layout_width="match_parent"
android:layout_height="48dp"/>
<View
android:id="@+id/group_header2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@+id/group_header1" />
<View
android:id="@+id/group_header3"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@+id/group_header2"/>
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/group_header3"
android:layout_above="@+id/group_header4"/>
<View
android:id="@+id/group_header4"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_above="@+id/group_header5" />
<View
android:id="@+id/group_header5"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true" />
</RelativeLayout>