1

我有一个由 BaseAdapter 备份的 ListView。我正在使用的布局是一个相对布局,其中一些 TextViews 和 ImageViews 呈现正常。问题是我想将列表中的某些项目变灰。我创建了一个空的 RelativeLayout,它应该与父级的高度和宽度相匹配,但它根本不会呈现,除非我在其中放置一个 TextView。为什么会出现这种行为,如何将 ListView 项目变灰?

谢谢!

布局在这里:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="10dp"
    android:paddingTop="10dp" >

    <RelativeLayout
        android:id="@+id/leftIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="10dp" >

        <ImageView
            android:id="@+id/item_arrow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/list_item_arrow"
            android:contentDescription="@null"
            android:visibility="gone" />

        <ImageView
            android:id="@+id/item_plus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/icon_plus"
            android:contentDescription="@null"
            android:visibility="gone" />

        <ImageView
            android:id="@+id/item_arrow_down"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/list_item_arrow_down"
            android:contentDescription="@null"
            android:visibility="gone" />
    </RelativeLayout>

    <TextView
        android:id="@+id/textViewCount"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dip"
        android:layout_marginRight="20dip"
        android:layout_toLeftOf="@id/leftIcon"
        android:textColor="@color/font_dark_gray"
        android:textSize="17sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/menu_item_name"
        style="@style/MenuRowStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dp"
        android:layout_toLeftOf="@id/textViewCount"
        android:ellipsize="end"
        android:lines="1" />
</RelativeLayout>

<!-- Problematic overlay layout -->
<RelativeLayout
    android:id="@+id/overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="grey_color_code"
    android:layout_centerInParent="true"
    android:visibility="visible" >
    <!-- If this is not here the overlay doesn not render on screen -->
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dip"
        android:layout_marginRight="20dip"
        android:layout_toLeftOf="@id/leftIcon"
        android:textColor="@color/font_dark_gray"
        android:textSize="17sp"
        android:textStyle="bold" />
</RelativeLayout>

</RelativeLayout>
4

0 回答 0