ListView控件忽略WRAP_CONTENT [英] ListView ignoring wrap_content

查看:161
本文介绍了ListView控件忽略WRAP_CONTENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在Android的ListView的一个问题。 当我设置安卓layout_height =WRAP_CONTENT,ListView的停留只有一两行长,我不能找到一个办法让他包装。

I have a problem with the ListView in Android. When I set android:layout_height="wrap_content", ListView stays just one or two rows long and I can't find a way to make him "wrapped".

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:gravity="center">
            <TextView
                android:id="@+id/question" 
                android:layout_width="fill_parent"  
                android:layout_height="wrap_content" />
            <ListView android:id="@+id/ListView01"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </ScrollView>
</FrameLayout>

有没有办法做到这一点?在此先感谢!

Is there any way to accomplish this? Thanks in advance!

推荐答案

看来你要一个头添加到您的列表视图。 列表视图内置了支持页眉(页脚)。该方法用于设置一个标题是 listview.addHeader(查看视图)。您可以根据需要自定义标题。

It appears you're trying to add a header to your listview. Listview has built-in support for headers (and footers). The method for setting a header is listview.addHeader(View view). You can customize the header as needed.

这篇关于ListView控件忽略WRAP_CONTENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆