ListView不占用整个屏幕

时间:2012-06-08 05:16:39

标签: android android-listview

我已经尝试了android:backgroundandroid:cacheColorHint以及@android:color/transparent@null的所有可能选项,但没有用来隐藏图片中的listView。

我正在尝试将灰色背景(粉红色问号)与我应用的白色主题合并。

我的主题是常规@android:style/Theme.Light.NoTitleBar

我的布局代码是

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

任何提示?

enter image description here

1 个答案:

答案 0 :(得分:1)

我所知道的唯一解决方案是根据需要创建一个宽度为1dp和高度的Button,并将其放在列表下以填写其余部分。

我提前为这个相当“肮脏”的建议道歉 - 但是当你继续遇到这种问题时,尝试了bottom_margins,paddings,固定大小的背景,......我还没有找到任何一种“干净”的解决方案

期待就这一主题提出更好的工作建议: - )

相关问题