【问题标题】:Expandable List View - Fixed Height with scroll to children可扩展列表视图 - 固定高度,滚动到子级
【发布时间】:2015-01-09 12:20:19
【问题描述】:

我已按照 this 教程了解可扩展列表视图的使用。

这是我想要达到的目标:

[第 1 组]

[第 2 组]

[Group 3] --- 固定高度

  • [孩子 1]

.......

…………

…………

  • [孩子 30]

[Group 4] - 3 个项目的可扩展列表

[Group 5] - 3 个项目的可扩展列表

上面的整个布局不应该滚动,我的意思是所有的组应该是可见的,只有第三组应该是可见的,启用滚动。

谁能帮我解决这个问题?

【问题讨论】:

    标签: android listview expandablelistview expandablelistadapter


    【解决方案1】:

    所以我猜你的意思是你想要的是当每个组被点击时。该组已展开,其余组仍然可见。这意味着孩子们会在小组之间“挤进去”。

    第一种方法是添加一个固定大小的滚动视图(或列表视图)作为可扩展列表视图中每个组的唯一子项。虽然根据我自己的经验,我知道嵌套滚动容器的工作非常糟糕,所以我会这样做:

    不要使用可扩展列表视图,而是使用五个视图,它们看起来就像可扩展列表视图中的组行,并且在单击组时。您在单击的行下方添加一个固定大小的滚动视图/列表视图。你认为这对你有用吗?

    如何工作的一个示例就像我在下面显示的代码一样。使用您喜欢的任何类型的视图/按钮/文本视图作为组标题。

    <?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>
    

    【讨论】:

    • 第一件事是 [Group 3] 具有固定高度和可滚动的孩子,这是我需要实现的主要目标
    猜你喜欢
    • 1970-01-01
    • 2020-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多