开发者

Android header and footer overlapping the screen

In my app i want to have two static parts as header and footer. i added this in layout xml and using relative layout it worked fine for me. But when i tried to add a header xml separately using include. The header and mid screen view overlapping. pls suggest how can i eliminate this.

here is the header xml,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
    <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="*">
        <TableRow android:layout_width="wrap_content" android:layout_height="10px" android:gravity="center|center_vertical|center_horizontal">
            <ImageView android:id="@+id/icon" android:src="@drawable/iconhome" android:layout_width="wrap_content" android:layout_gravity="left" android:layout_height="wrap_content"/>
            <TextView android:text="Application" android:id="@+id/txtTitlevalue" android:textColor="#800517"  android:textSize="18px" android:layout_height="wrap_content" android:gravity="center|left" android:textStyle="bold" android:layout_width="wrap_content" android:layout_weight="1"/>
        </TableRow>
        <TableRow android:layout_width="fill_parent" android:layout_height="15px" android:background="#800517" android:gravity = "center|center_vertical">
            <TextView android:text=" \n " android:layout_height="3px"/>
        </TableRow>
    </TableLayout>  
</RelativeLayout>

and other xml where i am including header.xml is,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include android:layout_height="wrap_content" layout="@layout/header" />
        <ScrollView android:layout_width="fill_parent"  android:layout_height="wrap_content">
        <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="15px" android:stretchColumns="*">
        <TableRow android:layout_width="fill_parent" android:layout_height="15px" android:padding="5px" android:gravity="center_vertical|left">
            <TextView android:text=" SEARCH FOR PROPERTY " android:layout_height="wrap_content" android:textSize="14px" android:textColor="#000000"/>
            <ImageView android:id="@+id/redarrow" android:src="@drawable/redarrow" android:layout_width="wrap_content" android:layout_gravity="left" android:layout_height="wrap_content"/>
        </TableRow>
        <TableRow android:layout_width="fill_parent" android:layout_height="15px" android:gravity = "center_vertical">
                <TextView android:id="@+id/acct_number1" android:layout_width="fill_parent" android:layout_height="25px" android:text="  I want to: " android:background="#EBDDE2" android:textColor="#000000" android:textSize="13px" android:gravity="center_vertical" android:layout_weight="1"/>
        </TableRow>     
        <TableRow android:layout_width="fill_parent" android:paddingLeft="15px" android:paddingTop="3px" android:paddingBottom="3px" android:paddingRight="15px" android:layout_height="15px" android:gravity = "center_vertical"开发者_开发知识库>
                <RadioButton android:text="Buy" android:id="@+id/radioButton1" android:textColor="#000000" android:textSize="13px" android:layout_width="0dip" android:layout_height="40px"/>
                <RadioButton android:text="Rent" android:id="@+id/radioButton2" android:textColor="#000000" android:textSize="13px"  android:layout_width="wrap_content" android:layout_height="40px"  android:layout_weight="1"/>
        </TableRow>
        </TableLayout>
        </ScrollView>
</RelativeLayout>

thanks,


header.xml --->

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
    <TableLayout android:layout_width="fill_parent" android:layout_alignParentTop="true" android:layout_height="wrap_content" android:stretchColumns="*">
        <TableRow android:layout_width="wrap_content"  android:background="#FFFFFF" android:layout_height="10px" android:gravity="center|center_vertical|center_horizontal">
            <ImageView android:id="@+id/icon" android:src="@drawable/iconhome" android:layout_width="wrap_content" android:layout_gravity="left" android:layout_height="wrap_content"/>
            <TextView android:text="Mobile Property" android:id="@+id/txtTitlevalue" android:textColor="#800517"  android:textSize="18px" android:layout_height="wrap_content" android:gravity="center|left" android:textStyle="bold" android:layout_width="wrap_content" android:layout_weight="1"/>
        </TableRow>
    </TableLayout>  
</RelativeLayout>

Main.xml (middle) --->

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


<ScrollView android:layout_width="fill_parent"  android:layout_height="wrap_content">
<TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="15px" android:stretchColumns="*">
<include android:layout_height="wrap_content" layout="@layout/header" android:layout_alignParentTop="true" android:id="@+id/cell1" />

        <TableRow android:layout_width="fill_parent" android:layout_height="15px" android:padding="5px" android:gravity="center_vertical|left">
            <TextView android:text=" SEARCH FOR PROPERTY " android:layout_height="wrap_content" android:textSize="14px" android:textColor="#FFFFFF" android:textStyle="bold"/>
            <ImageView android:id="@+id/redarrow" android:src="@drawable/redarrow" android:layout_width="wrap_content" android:layout_gravity="left" android:layout_height="wrap_content"/>
        </TableRow>

        <TableRow android:layout_width="fill_parent" android:layout_height="15px" android:gravity = "center_vertical">
                <TextView android:id="@+id/acct_number1" android:layout_width="fill_parent" android:layout_height="25px" android:text="  I want to: " android:textColor="#FFFFFF" android:textSize="13px" android:gravity="center_vertical" android:layout_weight="1"/>
        </TableRow>     
        <TableRow android:layout_width="fill_parent" android:paddingLeft="15px" android:paddingTop="3px" android:paddingBottom="3px" android:paddingRight="15px" android:layout_height="15px" android:gravity = "center_vertical">
                <RadioButton android:text="Buy" android:id="@+id/radioButton1" android:textColor="#FFFFFF" android:textSize="13px" android:layout_width="0dip" android:layout_height="40px"/>
                <RadioButton android:text="Rent" android:id="@+id/radioButton2" android:textColor="#FFFFFF" android:textSize="13px"  android:layout_width="wrap_content" android:layout_height="40px"  android:layout_weight="1"/>
        </TableRow>
        <TableRow android:layout_width="fill_parent" android:layout_height="15px" android:gravity = "center_vertical">
                <TextView android:id="@+id/acct_number1" android:layout_width="fill_parent" android:layout_height="25px" android:text="  Property Type: " android:textColor="#FFFFFF" android:textSize="13px" android:gravity="center_vertical" android:layout_weight="1"/>
        </TableRow>

<include android:layout_height="wrap_content" layout="@layout/footer" android:layout_alignParentBottom="true" android:id="@+id/cell" />
</TableLayout>
</ScrollView> 
</RelativeLayout>

footer.xml --->

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_alignParentBottom="true"
  android:layout_height="wrap_content"
  android:gravity="center_vertical|center_horizontal|bottom">
<TableLayout android:gravity="center_vertical|center_horizontal|bottom" android:layout_gravity="bottom" android:layout_alignParentBottom="true" android:layout_width="fill_parent" android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:stretchColumns="*">
    <TableRow android:layout_width="fill_parent" android:background="#FFFFFF" android:gravity = "center_vertical">
        <ImageView android:id="@+id/footerMessageIcon" android:layout_width="wrap_content" android:layout_weight="70" android:layout_gravity="bottom" android:src="@drawable/iconcheck" android:layout_height="wrap_content"/>
        <ImageView android:id="@+id/footerCalendarIcon" android:layout_width="wrap_content" android:layout_weight="70" android:layout_gravity="bottom" android:src="@drawable/iconstar" android:layout_height="wrap_content"/>
        <ImageView android:id="@+id/footerAccountsIcon" android:layout_width="wrap_content" android:layout_weight="70" android:layout_gravity="bottom" android:src="@drawable/icontools" android:layout_height="wrap_content"/>
    </TableRow>
</TableLayout>  
</LinearLayout>


use LinearLayout instead of RelativeLayout in second xml..


try this...

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@drawable/investment"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<include android:layout_height="wrap_content" layout="@layout/header" android:layout_alignParentTop="true" android:id="@+id/cell1" />

<ScrollView android:layout_width="fill_parent"  android:layout_height="wrap_content"  
 android:layout_below="@+id/cell1" android:layout_above="@+id/cell">
<TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="15px" android:stretchColumns="*">


        <TableRow android:layout_width="fill_parent" android:layout_height="15px" android:padding="5px" android:gravity="center_vertical|left">
            <TextView android:text=" SEARCH FOR PROPERTY " android:layout_height="wrap_content" android:textSize="14px" android:textColor="#FFFFFF" android:textStyle="bold"/>
            <ImageView android:id="@+id/redarrow" android:src="@drawable/redarrow" android:layout_width="wrap_content" android:layout_gravity="left" android:layout_height="wrap_content"/>
        </TableRow>

        <TableRow android:layout_width="fill_parent" android:layout_height="15px" android:gravity = "center_vertical">
                <TextView android:id="@+id/acct_number1" android:layout_width="fill_parent" android:layout_height="25px" android:text="  I want to: " android:textColor="#FFFFFF" android:textSize="13px" android:gravity="center_vertical" android:layout_weight="1"/>
        </TableRow>     
        <TableRow android:layout_width="fill_parent" android:paddingLeft="15px" android:paddingTop="3px" android:paddingBottom="3px" android:paddingRight="15px" android:layout_height="15px" android:gravity = "center_vertical">
                <RadioButton android:text="Buy" android:id="@+id/radioButton1" android:textColor="#FFFFFF" android:textSize="13px" android:layout_width="0dip" android:layout_height="40px"/>
                <RadioButton android:text="Rent" android:id="@+id/radioButton2" android:textColor="#FFFFFF" android:textSize="13px"  android:layout_width="wrap_content" android:layout_height="40px"  android:layout_weight="1"/>
        </TableRow>
        <TableRow android:layout_width="fill_parent" android:layout_height="15px" android:gravity = "center_vertical">
                <TextView android:id="@+id/acct_number1" android:layout_width="fill_parent" android:layout_height="25px" android:text="  Property Type: " android:textColor="#FFFFFF" android:textSize="13px" android:gravity="center_vertical" android:layout_weight="1"/>
        </TableRow>


</TableLayout>
</ScrollView> 
<include android:layout_height="wrap_content" layout="@layout/footer"    
android:layout_alignParentBottom="true" android:id="@+id/cell" />
</RelativeLayout>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜