Черное пространство под заголовком при использовании собственного фона для просмотра списка - PullRequest
3 голосов
/ 13 декабря 2011

Я создал пользовательский заголовок для всех своих действий просмотра списка, используя следующий файл window_title.xml

window_title.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="35dp"
        android:gravity="center_vertical"
        android:paddingLeft="5dp"
        android:background="#323331">

        <ImageView
                android:id="@+id/header"
                android:src="@drawable/ic_launcher"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="right|center_vertical"
            android:paddingRight="5dp" >

                <TextView
                        android:id="@+id/title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="11dp"
                        android:paddingRight="5dp" />

            <ImageView
                        android:id="@+id/icon"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"/>

        </LinearLayout>

</LinearLayout>

My main.xml

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


    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:drawSelectorOnTop="false"
        android:background="#CFECEC"
        android:cacheColorHint="#00000000"/>

</RelativeLayout>

list_item.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="fill_parent"
    android:orientation="horizontal"
    android:padding="8dp" >

    <ImageView
        android:id="@+id/icon"
        android:layout_width="22dp"
        android:layout_height="22dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="4dp"
        android:src="@drawable/list_icon" >
    </ImageView>

    <TextView
        android:id="@+id/firstName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#4AA02C"
        android:textSize="20dp"
        android:layout_marginLeft="38dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/lastName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="2dp"
        android:layout_toRightOf="@id/firstName"
        android:textColor="#4AA02C"
        android:textSize="20dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/firstName"
        android:textColor="#254117"
        android:textSize="12dp" 
        android:layout_marginLeft="38dp"/>

</RelativeLayout>

Это скриншот действия.

ScreenShot of Main Activity

Здесь вы можете заметить черное пространство под заголовком заголовка.Как это можно удалить?

Ответы [ 3 ]

4 голосов
/ 13 декабря 2011

Поиграйте со значениями `padding, paddingTop, paddingRight в корневом линейном макете вашего window_title.xml.Для строки заголовка это должно быть установлено на 0 со всех сторон.

Также, как @Ravi Bhatt указывает, что mail.xml содержит верхний отступ 4. Удалите это.

2 голосов
/ 13 декабря 2011

Я думаю, android:paddingTop="4dp" в вашем относительном расположении My Main.xml является проблемой. Попробуйте после удаления этого.

1 голос
/ 13 декабря 2011

Попробуйте с android:paddingBottom.Может быть, это сработает.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...