Black space under the title bar using the custom background for listview

advertisements

I have created a custom titlebar for all my listview activities using the following 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>

This is a screenshot of the activity.

Here you can notice a black space below the titlebar. How can this be removed?


I think android:paddingTop="4dp" in your relative layout of My Main.xml is the problem. Try after removing that.