Droid 3上的Listview背景是灰色的

12

我有一个带自定义背景的列表框。它在两侧显示一条薄白线,黑色背景。在所有测试手机上都很好用(Galaxy Captivate,Vibrant,Nexus 1,G Tablet,Archos 32,Droid)。我刚刚拿到了一个Droid 3来测试,在这个手机上,当没有项目时列表视图的背景是灰色的。列表项具有正确的黑色背景。

这里是包含列表视图的布局。列表视图上方和下方有白色背景文本框,列表视图的背景是可绘制的(我知道它被称为三边框,但实际上只是两个边框)。

<RelativeLayout
    android:layout_below="@id/divider01"
    android:layout_above="@id/save_current_button"
    android:id="@+id/profile_middle_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="3dip"
    android:orientation="vertical">
    <TextView  android:id="@+id/user_profile_row"
        android:text="@string/user_profiles_label"
        android:layout_alignParentTop="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textColor="@android:color/black"
        android:background="@drawable/roundedtop"/>
    <TextView android:id="@+id/current_profile_name"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textColor="#2B497B"
        android:background="@drawable/roundedbottom"/>
    <ListView android:id="@id/android:list"
        android:layout_below="@id/user_profile_row"
        android:layout_above="@id/current_profile_name"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingLeft="3dip"
        android:paddingRight="3dip"
        android:drawSelectorOnTop="false"
        android:background="@drawable/three_side_border"
        android:cacheColorHint="#ffffffff"/>
</RelativeLayout>

这里是drawable - 这应该会强制将背景设置为黑色。

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#FFFFFFFF" />
        </shape>
    </item>

    <item android:left="3dp" android:right="3dp"> 
        <shape android:shape="rectangle">
            <solid android:color="#FF000000" />
        </shape>
    </item>
</layer-list>

我注意到在我的列表项xml中,我的颜色没有指定alpha层,所以我尝试从我的可绘制对象中去掉前导的FF,但效果却是一样的。

有人知道我可以在哪里寻找解决方法吗?这在一个好手机上看起来非常丑陋。

谢谢, Greg


1
想补充一下,Droid 3 是2.3版本,但 Nexus 1 也是,所以我不认为这是 Android 的问题。其他设备都是2.2。 - gbryant
继续尝试。如果我将可绘制对象的外部形状更改为蓝色,则整个ListView的外部线条都会变成蓝色,但内部仍然是灰色。如果我将可绘制对象的内部形状更改为蓝色,则在列表项之间会显示一条细蓝线,但在列表项下方的空白区域中除了灰色以外什么也没有。因此,摩托罗拉已经覆盖了ListView的默认背景显示行为。 - gbryant
1个回答

24

我的朋友在摩托罗拉论坛上发现了一条评论:

摩托罗拉在2.3版本的Moto设备上更改了内置主题的属性值。 "如果您将overScrollFooter设置为@null,则列表底部的背景将变为透明,您的背景图像将显示出来...... 如果您想要一个不同的底部列表背景,则可以将overScrollFooter设置为颜色或可绘制对象..."

android:overScrollFooter="#aa000000"
android:overScrollFooter="@drawable/my_drawable"

http://community.developer.motorola.com/t5/MOTODEV-Blog/Why-Does-My-ListView-Look-Different/ba-p/17462

我还不能完全确定他们在渲染这个空间时在做什么,但我可以让它起作用。如果我使用drawable选项,并将我的带有左右边框的drawable传递给它,那么该对象会从listview背景中绘制 - 也就是说,它以某种方式仍然显示我的双层背景drawable中的第一个项目,因此现在我的列表项下方的空格具有更宽的边框,但是是黑色的。这至少与我之前的测试一致,当我将第一层更改为蓝色时,整个listview的高度都会出现蓝线。如果我只使用直接的黑色#ff000000,则listview看起来与我所有其他手机的外观相同。因此,我不确定他们如何计算页脚空间 - 我不明白他们怎么会知道我有一个双层对象并替换第二层。还有其他事情正在发生,我只是不理解,但它确实有效。

还有一条评论说你需要根据Android版本选择主题,但在我的测试中,所有平台都可以接受新标记而不会出现问题。


2
谢谢。这个问题的答案很难找到。 - spentak
3
摩托罗拉这次真是愚蠢。许多新款摩托设备上我的应用程序看起来都很糟糕,而我却不知道这一点。他们为什么要去动这样一个如此基本的东西呢? - SaKet
感谢您的回答,就像spentak所说,这是一个很难找到答案的问题,能够找到一个易于实现的解决方案真是一种解脱。 - dwemthy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接