Android First ListView scrolls down to only half of last entry with two ListViews

I have what I thought would be straight forward to implement: A linear layout with two ListViews, both with a layout_weight="1". The first one is "fill parent" and the second one is "wrap content". The idea is that the first ListView is to occupy the entire screen when the second ListView is empty, and when both had entries the screen would be shared. Well, it almost works but when the second ListView is empty, the first ListView scrolls down only half-way through the LAST entry. The remainder of the last entry is off the screen. Does anyone understand why that is the case?

Here is my layout:

<?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>

Actually at this stage I have not made an adapter for my second ListView so I have not been able to test it with entries in it. But the point is that it should be as if I did not have the ListView at all when it is empty. Alas such is not the case. When I remove the second ListView, the first one scrolls down to the last element correctly, displaying the entire entry.

Thanks for any insight!

Answers


Put in a line like android:paddingBottom="20dp" into your top ListView. Adjust the 20dp value until it looks the way you want it to. You can programmatically change the bottom padding as the list disappears and reappeares to make it look just right.


Need Your Help

field validation for string along with number in javascript

javascript validation

I have a password field in one form. Now I have to validate in such a way that the field value should be a 7 digits string along with a number. Otherwise it will return false.

Removing index.php in CodeIgniter using .htaccess file when using your own local domain

php .htaccess codeigniter mod-rewrite

I have seen other articles on the same issue. But none of the answers have solved my problem.