Android两个列表视图的间距和布局
我创建了以下布局,其中UI由两个线性布局组成,每个人都有一个标题文本视图和一个列表视图。我需要动态设置ListView高度,以便两者都能正确显示 现在是这样的: 看看第一个ListView下面的空白空间是如何被浪费的,而另一个ListView显示滚动条,并且可以利用额外的空间 布局xml如下所示:Android两个列表视图的间距和布局,android,android-layout,Android,Android Layout,我创建了以下布局,其中UI由两个线性布局组成,每个人都有一个标题文本视图和一个列表视图。我需要动态设置ListView高度,以便两者都能正确显示 现在是这样的: 看看第一个ListView下面的空白空间是如何被浪费的,而另一个ListView显示滚动条,并且可以利用额外的空间 布局xml如下所示: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:l
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Current outages"
android:paddingLeft="3sp"
android:background="@color/listHeader_Background"
android:textColor="@color/listHeader_Foreground"/>
<ListView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingLeft="3sp"
android:text="Resolved outages"
android:background="@color/listHeader_Background"
android:textColor="@color/listHeader_Foreground"/>
<ListView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
在子版面的高度上使用换行内容,而不是填充父版面。如果在包含ListView项的线性版面上设置android:layout\u height=WRAP\u内容,它不应该根据版面的大小进行收缩吗?