有些事情确实很愚蠢,但我想为我的列表视图设置最大高度,而且似乎找不到能起作用的方法。有些人谈论设置列表视图的最大高度,但我找不到这个选项?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="40dp" >
<ListView
android:id="@+id/lvSwitch"
android:layout_width="fill_parent"
android:layout_height="120dp" >
</ListView>
</LinearLayout>
但是当列表中只有一个项目时,它仍然具有120dp的高度,这是不必要的,当然它不能超过该高度...