BigT
BigT

Reputation: 1433

Image below ListView

I have this list view that is taking up the whole page. I want it to extend as far down as it can but I need an image underneath it. Right now the list extends all the way down to where my tab bar is but I need that picture in between. On my simulator it worked nicely before but I had a specified height, so when I tested it on a phone the height was a mess.

Here is my code:

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

    <RelativeLayout android:layout_width="wrap_content" android:layout_height="50dp">       
        <ImageView android:id="@+id/selfImage" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/navbar"/>
        <ImageView android:id="@+id/logoImage" android:layout_width="70dp" android:layout_height="46dp" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:background="@layout/border"/>
        <ImageView android:id="@+id/mainLogo" android:layout_width="50dp" android:layout_height="46dp" android:background="@drawable/corner_icon" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"/>
        <TextView android:id="@+id/nameTitle" android:text="Help" android:layout_width="130dp" android:layout_height="46dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:gravity="center" android:textColor="#C6DE52"/>
    </RelativeLayout>


    <RelativeLayout android:layout_width="310dp" android:layout_height="40dp">
        <EditText android:id="@+id/search"
            android:layout_height="match_parent"
            android:layout_width="280dp"
            android:hint="Search"/>
        <ImageButton
            android:id="@+id/favButton"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:background="@drawable/favorite" />

    </RelativeLayout>

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

   </ListView>

   <RelativeLayout android:layout_width="match_parent" android:layout_height="30dp">    
       <ImageView android:id="@+id/myImageView"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:background="@drawable/bottombar" />

       <TextView android:id="@+id/myImageViewText"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_alignLeft="@+id/myImageView"
           android:layout_alignTop="@+id/myImageView"
           android:layout_alignRight="@+id/myImageView"
           android:layout_alignBottom="@+id/myImageView"
           android:layout_margin="1dp"
           android:layout_alignParentLeft="true"
           android:text="For immediate assisstance call"
           android:textColor="#C6DE52" />

       <Button android:id="@+id/urgentNumButton"
           android:layout_width="120dp"
           android:layout_height="match_parent"
           android:layout_alignParentRight="true"
           android:paddingLeft="5dp"
           android:paddingTop="2dp"
           android:textColor="#C6DE52"    
           android:gravity="left"           
           android:background="@android:color/transparent"
           android:onClick="onClick"/>
   </RelativeLayout>

</LinearLayout>   

Here is what the screen should do, (Image has a fixed height. I am trying to stay away from that)

enter image description here

Here is what it looks like now.

enter image description here

Any help would be great. Thanks

Upvotes: 0

Views: 1066

Answers (3)

Wahib Ul Haq
Wahib Ul Haq

Reputation: 4425

Already answered this in a separate question

You can do it in a better way by adding ImageView as Footer of ListView.

Upvotes: 0

Zar E Ahmer
Zar E Ahmer

Reputation: 34390

I have a Screen where Imageview is above and below the ListView may be this help..

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:background="@drawable/bg">

    <ImageView
        android:id="@+id/dept_nav"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/dept_nav" />

      <ListView
        android:id="@+id/list_of_f"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_margin="5dp"
        android:layout_below="@+id/dept_nav"
        android:layout_above="@+id/imageViewId"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:listSelector="@android:color/transparent" >
    </ListView>



        <ImageView
        android:id="@+id/imageViewId"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="2dp"
        android:scaleType="fitXY"
        android:src="@drawable/empty_cell" >
    </ImageView>

</RelativeLayout>

Upvotes: 0

marmor
marmor

Reputation: 28239

change the ListView to:

<ListView
       android:id="@+id/selfHelpList"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:layout_weight="1" />

This will cause the ListView to take over the entire screen, now add to all the over views above and below:

android:layout_weight="0"

So they'll take up as much space as they need, and then the ListView will get all the rest of the height.

Upvotes: 1

Related Questions