列表视图背景在Droid 3上是灰色的

gbr*_*ant 12 android listview background

我有一个自定义背景的列表框.它在两侧显示一条带有黑色背景的细白线.适用于我所有的测试手机(Galaxy Captivate,Vibrant,Nexus 1,G Tablet,Archos 32,Droid).我刚刚有一个Droid 3进行测试,在这一款手机上,listview的背景没有任何项目是灰色的.列表项具有正确的黑色背景.

这是包含列表视图的布局.列表视图上方和下方都有白色背景文本框,列表视图的背景是可绘制的(我知道它叫做三个边框,但它只有两个边框).

<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>
Run Code Online (Sandbox Code Playgroud)

这是可绘制的 - 这应该强制背景为黑色.

<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>
Run Code Online (Sandbox Code Playgroud)

我注意到在我的列表项xml中,我没有在我的颜色中指定alpha分层,所以我尝试在我的drawable上取下前导FF,但它出来了.

任何人都有任何想法,我可以解决这个问题?在一部漂亮的手机上看起来真的很难看.

谢谢,格雷格

gbr*_*ant 24

一位好友在摩托罗拉论坛上发表评论:

摩托罗拉用2.3更改了Moto设备上内置主题的属性值."如果你设置overScrollFooter@null,列表底部的背景变得透明,你的背景图像显示出......如果你想要一个列表底部的背景,但是另一个背景,你可以设置overScrollFooter为颜色或可绘制的. .."

android:overScrollFooter="#aa000000"
android:overScrollFooter="@drawable/my_drawable"
Run Code Online (Sandbox Code Playgroud)

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

在渲染这个空间时,我仍然不完全确定它们在做什么,但我可以让它工作.如果我使用drawable选项,并使用左边框和右边框将其绘制为drawable,那么该对象将从listview背景中绘制到边框内 - 即它仍以某种方式显示我的双层背景中的第一个项目drawable,因此我的列表项下面的空间现在有一个更宽的边框,但它是黑色的.这至少与我之前的测试一致,当我将第一层更改为蓝色,并在列表视图的整个高度上获得蓝线.如果我只使用直黑色#ff000000,那么listview看起来和我所有的其他手机一样.所以我不确定他们是如何计算页脚空间的 - 我不知道他们怎么知道我有一个双层对象而只是替换第二层.还有其他事情必须继续,我只是不明白,但确实有效.

还有一个评论,你需要根据Android版本选择一个主题,但到目前为止,在我的测试中,所有平台都采用新标签而不抱怨.

  • 这个从摩托罗拉真的很愚蠢.我的应用程序开始看起来很可怜​​许多新的Moto设备,而我却不知道这个...为什么他们会把这些东西弄得像这样. (3认同)
  • 谢谢你.这是一个很难找到答案的人 (2认同)