我有一个布局:ScrollView - > RelativeLayout - > TableLayout - > TableRow - > ListView。我不知道如何根据内容更改ListView的高度。我有一个适配器,但ListView的高度不会改变。它也不是可滚动的,但它不需要。我读过使用嵌套ListView是一种不好的做法,但我看不到任何解决方案,因为Column0中的图像源取决于多个变量(它不需要适配器)。我不能使用LinearLayout而不是ListView,因为我需要一个适配器。调整嵌套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"
>
我想拥有什么: The conception
你似乎使用'match_parent'作为你的'ListView'的高度...... –
如果我使用match_parent或wrap_content作为我的ListView或TableRow的高度,没有什么变化。我只能手动设置高度。 – adamsc
@adamsc看看这里,http://blog.lovelyhq.com/setting-listview-height-depending-on-the-items/ –