我有我认为可以直接实现的内容:带有两个ListView的线性布局,两个都有layout_weight =" 1"。第一个是#34;填充父母"第二个是"包装内容"。我们的想法是,当第二个ListView为空时,第一个ListView将占据整个屏幕,当两个ListView都有条目时,屏幕将被共享。好吧,它几乎可以工作,但是当第二个ListView为空时,第一个ListView只向下滚动一半通过LAST条目。最后一个条目的其余部分不在屏幕上。有谁理解为什么会这样?
这是我的布局:
<?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" >
<LinearLayout
android:id="@+id/dots"
android:layout_width="match_parent"
android:layout_height="24dp" >
</LinearLayout>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/lni_logo" />
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:choiceMode="none"
android:transcriptMode="alwaysScroll"
android:layout_weight="1"
android:id="@android:id/list" >
</ListView>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:choiceMode="none"
android:transcriptMode="alwaysScroll"
android:layout_weight="1"
android:id="@+id/rtsalist">
</ListView>
</LinearLayout>
实际上在这个阶段我还没有为我的第二个ListView做一个适配器,所以我无法用它中的条目来测试它。但重点是它应该就好像我没有ListView一样,当它是空的时候。唉,事实并非如此。当我删除第二个ListView时,第一个正确向下滚动到最后一个元素,显示整个条目。
感谢您的任何见解!
答案 0 :(得分:0)
将android:paddingBottom="20dp"
之类的行放入您的顶级ListView。调整 20dp 值,直到它看起来像您想要的那样。您可以以编程方式更改底部填充,因为列表消失并重新出现以使其看起来恰到好处。