android - 如何使 ListView 增长而不是滚动?

标签 android listview header scroll

我有一个 ListView,我在其中添加了一个标题。 header 包含另一个 ListView。我希望 header 中的 ListView 增长而不是滚动限制大小。

这是我在标题中膨胀的

    <ListView android:id="@+id/songinfo_geninfolist"
        android:isScrollContainer="false" android:layout_marginLeft="10dip"
        android:layout_margin="5dip" android:padding="5dip"
        android:scrollbars="none" 
        android:layout_height="wrap_content" android:layout_width="match_parent">
    </ListView>

这个 xml 用于主列表

<ListView android:id="@+id/songinfo_linklist"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_marginTop="10dip" android:layout_margin="5dip"
    android:layout_height="match_parent" android:layout_width="match_parent">
</ListView>

但我得到一个列表,其中包含一个高度较小的列表的标题。我希望标题中的列表随内容一起增长。

最佳答案

如果您希望您的列表随其内容一起增长,请不要使用 ListView。使用即 LinearLayout 并向其添加元素。

也可以尝试给上面的ListView一个固定的高度(即100dip),让下面的ListView占据剩下的空间。

您还必须知道 layout_heigth 参数与其他小部件/布局相比的工作方式不同。 IE。 wrap_content 没有意义,因为 ListView 可以显示数千个项目并且会占用整个内存。

如果你想使用 ListViews 你应该看过 google io session world of listview作者:罗曼盖伊。

关于android - 如何使 ListView 增长而不是滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6596262/

相关文章:

android - BroadcastReceiver 尝试在无序广播期间返回结果 - Android 中的 PACKAGE_ADDED

jquery - 动态添加列表项到 j-Query Mobile ListView

android - 将 JSON 从此链接填充到 android Listview

html - 如何卡住页面的标题

html - 页眉和页脚没有到达网页的边缘

android - ionic 2错误中的本地存储

java - 空连接变量

android - 使用 Cordova 构建时定义 Android Gradle 插件版本

android - 手势不适用于 Android 上的 ListView 项目

jsp - IE8 的 P3P 设置 header 似乎不起作用