Верхний и нижний колонтитулы Android перекрывают экран

В моем приложении я хочу иметь две статические части: верхний и нижний колонтитулы. я добавил это в макет xml, и с использованием относительного макета он отлично сработал для меня. Но когда я попытался добавить XML-заголовок отдельно, используя include. Заголовок и средний экран перекрываются. Пожалуйста, предложите, как я могу устранить это.

вот заголовок 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>

и другой xml, где я включаю header.xml,

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

Благодарность,


person rajesh    schedule 25.04.2011    source источник


Ответы (3)


заголовок.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 (посередине) --->

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

нижний колонтитул.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>
person Rajesh    schedule 26.04.2011
comment
capDroid, Вы великолепны. Большой дорогой и большое спасибо брату. На этот раз его рабочий пресс в порядке. -- Раджеш - person Rajesh; 26.04.2011
comment
добро пожаловать, брат... n также прими ответ, чтобы другой пользователь мог получить правильный ответ.. - person Niranj Patel; 26.04.2011

используйте LinearLayout вместо RelativeLayout во втором xml..

person Niranj Patel    schedule 25.04.2011
comment
сделано, изменил параметр android:layout_height на wrap_content второго xml. благодаря. - person rajesh; 25.04.2011
comment
Но таким образом мой нижний колонтитул.xml не отображается, так как я изменил среднюю часть, так как линейный макет, а нижний колонтитул - относительный макет. Это работало хорошо, если средний xml имел относительный макет. - person rajesh; 25.04.2011
comment
да, дорогой, это не разрешено.. это разрешено для заголовка, но когда средний макет изменился на линейный, он скрыл нижний колонтитул xml. - person rajesh; 26.04.2011
comment
Вы хотите, чтобы заголовок отображался вверху, а ScrollView - внизу заголовка? - person Niranj Patel; 26.04.2011
comment
Я хочу, чтобы верхний и нижний колонтитулы, а также средняя часть были прокручиваемыми. - person rajesh; 26.04.2011
comment
а верхний и нижний колонтитулы будут видны все время статически, а средний xml прокручивается, а не статичен. - person rajesh; 26.04.2011
comment
см. мой новый ответ .. в этом ответе установите заголовок вверху и прокрутку под заголовком, и вам нужен нижний колонтитул, поэтому вы установите нижний колонтитул внизу = true и прокрутку над нижним колонтитулом и установите высоту прокрутки как fill_parent .. - person Niranj Patel; 26.04.2011
comment
и не могли бы вы рассказать мне макет всех трех XML-файлов. я беру заголовок как относительный, а средний как линейный (как ты сказал вчера), а нижний колонтитул снова относительный. - person rajesh; 26.04.2011
comment
сначала возьмите родительский относительный макет и все три макета в родительском.. 1) установите заголовок android: layout_alignParentTop = true 2) установите нижний колонтитул android: layout_alignParentBottom = true 3) средний макет над нижним колонтитулом и под заголовком .. это будет работать .. - person Niranj Patel; 26.04.2011
comment
да, capDroid так работает. на этот раз все три XML-файла видны, но содержимое середины XML-файла перекрывает верхний и нижний колонтитулы, перекрывая середину. - person rajesh; 26.04.2011
comment
Итак, главная страница — это заголовок, три изображения — в нижнем колонтитуле, остальные — в прокрутке, верно? - person Niranj Patel; 26.04.2011
comment
Да, точно. заголовок с домом будет вверху на всех страницах. и эти три кнопки с нижним колонтитулом. - person rajesh; 26.04.2011
comment
но если мы это сделаем, весь экран будет прокручиваться. - person rajesh; 26.04.2011
comment
это может быть какая-то ошибка в коде, иначе это невозможно.. позвольте мне показать весь код макета.. - person Niranj Patel; 26.04.2011

попробуй это...

    <?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>
person Niranj Patel    schedule 26.04.2011