Add ImageView to a ListActivity

503 Views Asked by At

I would like to add an ImageView under my ListView in my ListActivity. So that when the user scrolls to the end of the list, the ImageView shows.

I can't seem to get my layout correct. Either the ImageView is not displayed at all, or if I use layout_weights, then both the ListView and ImageView get 50% of the screen. Any ideas how I can get what I want? Thanks.

<?xml version="1.0" encoding="utf-8" ?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ListView
        android:id="@+id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/> 

    <TextView
        android:id="@+id/android:empty"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/list_no_items" />

    <ImageView
        android:id="@+id/instruct_image"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/instructions"/>
</LinearLayout>
1

There are 1 best solutions below

3
On BEST ANSWER

Unfortunately I don't think what you want to accomplish is easily done with standard Android layouts. You can't have a ListView within another ScrollView.

You could use the ListView footer to position the ImageView below the ListView.

Or, you could try to add the ImageView as the last row in the ListView. To do this, override the getView method of the adapter and return the ImageView if it is the last row.