DroidMatt
DroidMatt

Reputation: 183

Fitting image layout

Attached image shows an interface. Notice the black part on the bottom. How do I pull my footer image to the bottom? I used fill_parent on my middle layout but it fills the whole screen and the footer wont show.

enter image description here

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

  <RelativeLayout 
    android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >

    <!--  Header Starts-->
          <LinearLayout 
              android:id="@+id/headerForSearch"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:background="@layout/headerbackground"
              android:paddingTop="5dip"
              android:weightSum="1"
              android:gravity="center"
              >

              <ImageView 
                  android:src="@drawable/footprint" 
                  android:layout_width="wrap_content" 
                  android:layout_weight="0.09" 
                  android:layout_height="fill_parent">
              </ImageView>

          </LinearLayout>  
    <!--  Header Ends -->


     <!-- About Us  -->
        <LinearLayout android:id="@+id/searchPBody" android:layout_width="fill_parent"         android:layout_height="wrap_content"    android:padding="10dip" android:orientation="vertical" android:layout_below="@+id/headerForSearch" android:layout_alignParentLeft="true">
     <ImageView android:layout_marginTop="10dip"  
               android:layout_width="wrap_content" 
               android:layout_height="wrap_content"
               android:src="@drawable/about_us_header"                     
               />          
    </LinearLayout> 
 <!--  Login Form Ends -->



<RelativeLayout
android:id="@+id/searchPBody2"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginRight="15dip"
android:layout_marginLeft="15dip"
android:layout_marginTop="15dip"
android:layout_marginBottom="15dip"
android:layout_below="@+id/searchPBody">

        <TextView android:text="Place Name:" 
            android:layout_marginTop="23dip"  
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:textColor="@color/black"
            android:id="@+id/placeNameTV" />

        <EditText android:hint="Type here"
            android:id="@+id/searchQuery"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:layout_marginLeft="15dip"
            android:layout_toRightOf="@+id/placeNameTV"/>

</RelativeLayout>

    <LinearLayout
            android:id="@+id/searchBtnLayout"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:layout_below="@+id/searchPBody2">

    <Button
        android:id="@+id/submitQuery"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Submit"
        android:layout_below="@+id/searchQuery"
        android:layout_toRightOf="@+id/placeNameTV"/>


    </LinearLayout>

<!--  Footer Starts -->


<LinearLayout
    android:id="@+id/footer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/searchBtnLayout"
    android:background="@layout/footer_repeat"
    android:gravity="center" 
    android:layout_alignParentBottom="true">

               <TextView android:textSize="12dip" 
                  android:textColor="#ffffff" 
                  android:text = "© Meet&Co" 
                  android:layout_width="wrap_content" 
                  android:layout_marginTop="10dip" 
                  android:layout_height="wrap_content" 
                  android_weight="0.33" />    
</LinearLayout>

<!--  Footer Ends -->
</RelativeLayout>     
</ScrollView>

Upvotes: 0

Views: 117

Answers (3)

MKJParekh
MKJParekh

Reputation: 34301

You can use weight attribute.

for example see the headerfooter.xml in this answer you can make your xml like that.

Upvotes: 1

Jave
Jave

Reputation: 31846

Easiest way is to use a RelativeLayout for your entire layout. You can then set the footer attribute layout_alignParentBottom="true" which moves it to the bottom. You will also have to set the body to layout_above="@+id/idoffooter", so that it does not disappear behind the footer.
Another way would be to use a vertical LinearLayout where you give the body a weight of 1, but the RelativeLayout way is imho better.

Upvotes: 0

Yvan RAJAONARIVONY
Yvan RAJAONARIVONY

Reputation: 571

Using fill_parent on middle layout make your middle layout take all screen height left. You can have relative layout as main layout and set footer android:layout_alignParentBottom="true".

Upvotes: 0

Related Questions