我有一个带有自定义背景的列表框。它在黑色背景的两侧显示一条细白线。在我所有的测试手机(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>
这是可绘制的 - 这应该将背景强制为黑色。
<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,但结果是一样的。
有人有什么想法可以解决这个问题吗?在一部漂亮的手机上看起来真的很难看。
谢谢,
格雷格
有哥们在摩托罗拉论坛上发现一条评论:
摩托罗拉更改了 Moto 设备上内置主题的属性值
与2.3。 “如果你设定overScrollFooter
to @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 http://community.developer.motorola.com/t5/MOTODEV-Blog/Why-Does-My-ListView-Look-Different/ba-p/17462
我仍然不完全确定他们在渲染这个空间时在做什么,但我可以让它工作。如果我使用可绘制选项,并为其提供具有左边框和右边框的可绘制对象,则该对象将从列表视图背景的边框内绘制 - 即,它仍然以某种方式显示我的两层背景可绘制对象中的第一个项目,因此我的列表项下方的空间现在有更宽的边框,但它是黑色的。这至少与我之前的测试一致,当时我将第一层更改为蓝色,并在列表视图的整个高度上得到一条蓝线。如果我只选择纯黑色#ff000000
,然后列表视图看起来与我所有其他手机相同。所以我不确定他们如何计算页脚空间 - 我不明白他们如何知道我有一个双层对象并且只是替换第二层。肯定还有其他事情发生,我只是不明白,但它确实有效。
还有评论说你需要根据 Android 版本选择一个主题,但到目前为止,在我的测试中,所有平台都毫无抱怨地采用了新标签。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)