Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android片段列表视图部分显示项目_Android_Listview_Layout_Height - Fatal编程技术网

android片段列表视图部分显示项目

android片段列表视图部分显示项目,android,listview,layout,height,Android,Listview,Layout,Height,我有一个带有关联activity.xml代码的活动: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/pattern_background" android:orientation="ver

我有一个带有关联activity.xml代码的活动:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/pattern_background"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginBottom="5dp"
    android:layout_weight="1"
    android:clickable="false" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        ...

        <LinearLayout
            android:id="@+id/llComments"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:orientation="vertical" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />
    </LinearLayout>
</ScrollView>

<include
    android:id="@+id/layoutComments"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"        
    layout="@layout/widget_comentarios_fragment" >
</include>
与xml文件关联的片段是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"   
android:orientation="vertical">

<ListView
    android:id="@+id/comments"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="@color/transparent"
    android:dividerHeight="10dp"
    android:paddingLeft="@dimen/indicator_internal_padding"
    android:paddingRight="@dimen/indicator_internal_padding" />
</LinearLayout>

我无法解决的问题是,如果我不确定listview的高度,那么在活动中会在列表中显示多个项目(事实上,我正在显示一个和第三个项目)。它应该适应我通过适配器添加到片段列表中的尽可能多的项目。我在布局和视图中尝试了不同的高度组合,但仍然不起作用。也许我是在用另一个来取消一个

任何帮助都将不胜感激


提前谢谢

几天后我发现了确切的问题。我在ScrollView中加入了ListView,Android开发者显然不推荐这样做。 您可以在此处查看更多信息:

不管怎么说,如果你想做,你可以用黑客来做。看看这些建议:


对我来说,这很有效。问题解决了。

几天后,我找到了确切的问题。我在ScrollView中加入了ListView,Android开发者显然不推荐这样做。 您可以在此处查看更多信息:

不管怎么说,如果你想做,你可以用黑客来做。看看这些建议:

对我来说,这很有效。问题解决了

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"   
android:orientation="vertical">

<ListView
    android:id="@+id/comments"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="@color/transparent"
    android:dividerHeight="10dp"
    android:paddingLeft="@dimen/indicator_internal_padding"
    android:paddingRight="@dimen/indicator_internal_padding" />
</LinearLayout>