列表视图背景是灰色的Droid 3的 [英] Listview background is grey on Droid 3

查看:106
本文介绍了列表视图背景是灰色的Droid 3的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义背景列表框。它显示一个细白线两边有黑色背景。伟大的作品在我所有的测试手机(银河Captivate的,充满活力,的Nexus 1,G平板电脑,爱可视32,Droid的)。我刚买了一台Droid 3的测试,并就这一个电话,列表视图的背景在没有项目是灰色的。该列表项具有正确的黑色背景。

下面是包含列表视图中的布局。 ListView控件具有白色背景的文本框的上方和下方,和背景对于ListView的绘制(我知道它被称为三个边境,但它只是一两个边界)。

 < RelativeLayout的
    机器人:layout_below =@ ID / divider01
    机器人:layout_above =@ ID / save_current_button
    机器人:ID =@ + ID / profile_middle_layout
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:paddingTop =3dip
    机器人:方向=垂直>
    < TextView的机器人:ID =@ + ID / user_profile_row
        机器人:文本=@字符串/ user_profiles_label
        机器人:layout_alignParentTop =真
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:重力=中心
        机器人:文字颜色=@机器人:彩色/黑白
        机器人:背景=@可绘制/ roundedtop/>
    < TextView的机器人:ID =@ + ID / current_profile_name
        机器人:layout_alignParentBottom =真
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:重力=中心
        机器人:文字颜色=#2B497B
        机器人:背景=@可绘制/ roundedbottom/>
    < ListView的机器人:ID =@ ID / Android的:清单
        机器人:layout_below =@ ID / user_profile_row
        机器人:layout_above =@ ID / current_profile_name
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:以下属性来=3dip
        机器人:paddingRight =3dip
        机器人:drawSelectorOnTop =假
        机器人:背景=@可绘制/ three_side_border
        机器人:cacheColorHint =#FFFFFFFF/>
< / RelativeLayout的>
 

下面是提拉 - 这应该迫使背景为黑色

 <层列表的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <项目>
        <形机器人:形状=矩形>
            [固体机器人:颜色=#FFFFFFFF/>
        < /形状>
    < /项目>

    <项目的android:左=3DP机器人:右=3DP>
        <形机器人:形状=矩形>
            [固体机器人:颜色=#FF000000/>
        < /形状>
    < /项目>
< /层列表>
 

我注意到,在我的列表项的xml,我没有在我指定的颜色的alpha层,所以我试图起飞领先FF在我的绘制,但当时就出来了。

任何人有任何想法,我可以期待解决这一问题?它看起来非常难看一个不错的手机。

谢谢, 格雷格

解决方案

一个哥们发现摩托罗拉论坛评论:

  

摩托罗拉改变属性值内置主题的摩托设备   2.3。 如果你设定 overScrollFooter @null ,底-名单   背景变得透明,你的背景图片显示   通过....如果希望底-的列表的背景下,但不同的   之一,你可以设置 overScrollFooter 来颜色或绘制...

 安卓overScrollFooter =#aa000000
机器人:overScrollFooter =@可绘制/ my_drawable
 

<一个href="http://community.developer.motorola.com/t5/MOTODEV-Blog/Why-Does-My-ListView-Look-Different/ba-p/17462">http://community.developer.motorola.com/t5/MOTODEV-Blog/Why-Does-My-ListView-Look-Different/ba-p/17462

我还不能完全肯定自己在做什么使这个空间的时候,但我可以得到它的工作。如果我使用的绘制选项,并给我的绘制与左右边框,该对象被从列表视图背景边框内绘制 - 即它以某种方式仍呈现在我的两层背景绘制的第一个项目,所以我下面的列表项的空间现在有一个较宽的边框,却是黑色的。这至少是与我以往测试一致时,我改变了第一层为蓝色,并得到了蓝线列表视图的整个高度。如果我只是去了黑直#FF000000 ,则列表视图看起来相同,我的所有其他手机。所以,我不知道他们是怎么计算的页脚空间 - 我不明白他们怎么会知道,我有一个两层的对象,只是被取代了第二层。有些东西必须回事,我只是不明白,但它的工作。

有一个同样是注释,你需要选择基于Android版本的一个主题,但到目前为止,在我测试的所有平台上采取新的标签没有抱怨。

I have a listbox with a custom background. It displays a thin white line on either side with a black background. Works great on all my test phones (Galaxy Captivate, Vibrant, Nexus 1, G Tablet, Archos 32, Droid). I just got a Droid 3 to test on, and on this one phone, the background of the listview where there are no items is grey. The list items have the correct black background.

Here's the layout containing the list view. The listview has white background text box above and below, and the background for the listview is the drawable (I know it's called a three border, but it's only a two border).

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

Here's the drawable - this should force the background to black.

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

I noticed that in my list item xml, I don't have the alpha layer specified in my colors, so I tried taking off the leading FF on my drawable, but it came out the same.

Anyone have any ideas where I can look to fix this? It looks really ugly on a nice phone.

Thanks, Greg

解决方案

A buddy found a comment on a Motorola forum:

Motorola changed attribute values for built-in themes on Moto devices with 2.3. "If you set overScrollFooter to @null, the bottom-of-list background becomes transparent and your background image shows through.... If you want a bottom-of-list background, but a different one, you can set overScrollFooter to a color or drawable..."

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

I'm still not entirely sure what they are doing when rendering this space, but I can get it to work. If I use the drawable option, and give it my drawable with the left and right borders, that object gets drawn inside the border from the listview background - i.e. it is somehow still showing the first item in my two-layer background drawable, so the space below my list items now has a wider border, but it is black. This is at least consistent with my earlier test when I changed the first layer to blue, and got a blue line the entire height of the listview. If I just go with a straight black #ff000000, then the listview looks the same as all my other phones. So I'm not sure how they are calculating the footer space - I don't see how they would know that I have a two-layer object and just be replacing the second layer. Something else must be going on that I just don't understand, but it does work.

There was a also a comment that you would need to select a theme based on the android version, but so far in my testing all the platforms take the new tag without complaining.

这篇关于列表视图背景是灰色的Droid 3的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆