Sana
Sana

Reputation: 9915

ListView doesn't occupy whole screen

I have tried all possible options for android:background and android:cacheColorHint with @android:color/transparent and @null but of no use to hide the listView in the picture.

I am trying to merge the gray background(pink question marks) with the white theme of my app.

My theme is the regular @android:style/Theme.Light.NoTitleBar

My layout code is

<?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:background="@android:color/transparent" >

    <LinearLayout
        android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1" >

        <ImageView
            android:id="@+id/abcIcon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_weight="0.15"
            android:contentDescription="@string/abcIcon"
            android:scaleType="centerInside"
            android:src="@drawable/abc" />

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_weight="0.70"
            android:text="@string/app_name"
            android:textSize="@dimen/headertextsize" />

        <ImageView
            android:id="@+id/search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_weight="0.15"
            android:contentDescription="@string/abcIcon"
            android:src="@drawable/search" />
    </LinearLayout>

    <RelativeLayout
        android:id="@+id/followupHeaderLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/header"
        android:layout_gravity="center_horizontal" >

        <RelativeLayout
            android:id="@+id/followupHeaderRelativeLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp" >

            <ImageView
                android:id="@+id/leftArrow"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:contentDescription="@string/abcIcon"
                android:src="@drawable/leftarrow" />

            <TextView
                android:id="@+id/followupHeaderText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/leftArrow"
                android:text="@string/followup"
                android:textSize="@dimen/headertextsize" />
        </RelativeLayout>

        <TextView
            android:id="@+id/followupDescriptionText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/followupHeaderRelativeLayout"
            android:layout_centerInParent="true"
            android:padding="10dp"
            android:text="@string/followupdescription"
            android:textSize="@dimen/normaltextsize" />
    </RelativeLayout>

    <TextView
        android:id="@+id/listViewHeaderText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/followupHeaderLayout"
        android:layout_marginLeft="10dp"
        android:text="@string/typeofAppt"
        android:textSize="@dimen/normaltextsize" />

    <RelativeLayout
        android:id="@+id/declarationLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="10dp" >

        <TextView
            android:id="@+id/widgetLabel"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="@string/declarationCompletion"
            android:textColor="@android:color/black"
            android:textSize="@dimen/normaltextsize" />

        <Button
            android:id="@+id/doneButton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/widgetLabel"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="15dp"
            android:background="#436EEE"
            android:gravity="left"
            android:paddingBottom="10dp"
            android:paddingLeft="5dp"
            android:paddingTop="10dp"
            android:text="@string/doneWithFollowup"
            android:textColor="@android:color/white"
            android:textSize="@dimen/normaltextsize" />
    </RelativeLayout>

    <ListView
        android:id="@+id/listViewFollowup"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/declarationLayout"
        android:layout_below="@id/listViewHeaderText"
        android:background="@android:color/transparent"
        android:cacheColorHint="@null"
        android:choiceMode="singleChoice" />

</RelativeLayout>

Any hints?

enter image description here

Upvotes: 0

Views: 1082

Answers (1)

user387184
user387184

Reputation: 11053

The only solution I know is to create a Button with width 1dp and height as you need and position this one under the list to fill out the rest.

I appologize in advance for this rather "dirty" advice - but as you I keep running into this kind of problem, tried bottom_margins, paddings, fixed sizes of backgrounds,.. I have not found any kind of "clean" solution.

Looking forward to better working suggestions on this topic too :-)

Upvotes: 1

Related Questions