Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.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 调整嵌套ListView的高度_Android_Android Layout_Listview - Fatal编程技术网

Android 调整嵌套ListView的高度

Android 调整嵌套ListView的高度,android,android-layout,listview,Android,Android Layout,Listview,我有一个布局:ScrollView->RelativeLayout->TableLayout->TableRow->ListView。我不知道如何根据内容更改ListView的高度。我有一个适配器,但ListView的高度不变。它也不可滚动,但不需要滚动。我已经读到使用嵌套ListView是一种不好的做法,但我看不到任何解决方案,因为Column0中图像的源依赖于多个变量(它不需要适配器)。我无法使用LinearLayout代替ListView,因为我需要适配器 例如: <ScrollVi

我有一个布局:ScrollView->RelativeLayout->TableLayout->TableRow->ListView。我不知道如何根据内容更改ListView的高度。我有一个适配器,但ListView的高度不变。它也不可滚动,但不需要滚动。我已经读到使用嵌套ListView是一种不好的做法,但我看不到任何解决方案,因为Column0中图像的源依赖于多个变量(它不需要适配器)。我无法使用LinearLayout代替ListView,因为我需要适配器

例如:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/ScrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" >
 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="1000dp"
        android:orientation="vertical" >
<TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:divider="#000000" 
            android:showDividers="middle" >

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <Button
                    android:id="@+id/button0"
                    android:layout_width="100sp"
                    android:layout_height="100sp"
                    android:layout_marginLeft="10sp"
                    android:layout_marginTop="10sp" />

                <ListView
                    android:id="@+id/listView0"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" 
                    >

我想要的是:
理想情况下,这样做是个坏主意


您可能可以编写一个自定义视图,扩展类似于
线性布局的内容,并支持使用适配器填充其中的视图。类似这样的情况:

您似乎正在使用
match\u parent
作为您的
ListView的高度
…如果我使用match\u parent或wrap\u content作为我的ListView或TableRow的高度,则不会发生任何变化。我只能手动设置高度。@adamsc看看这里,@K Neeraj Lal它可以工作,非常感谢您。您几乎可以重写ListView了吗?