【发布时间】:2013-10-24 11:20:08
【问题描述】:
我有一个使用列表视图来显示信息的应用程序,并且我已经放置了部分来划分不同类型的数据。这是一个屏幕截图,它在 Android 4.1.2 http://postimg.org/image/ujv765wf1/ 上的外观 它在 Android 4.0.3 上看起来一样,非常完美。
但是在运行 Android 4.3 的 Galaxy Nexus 上,这些部分的背景消失了,看起来像这样http://postimg.org/image/5ik2tayip/
图标和其他可绘制资源正确显示,但唯一的背景不是。它们之间的唯一区别是背景是在 XML 文件中声明的,而其他资源是通过编程方式添加的。
这是该部分的 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/greenstripe">
<ImageView
android:id="@+id/sectionIcon"
android:layout_width="45dip"
android:layout_height="37dip"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dip"
android:contentDescription="@string/emptyString" />
<TextView android:id="@+id/textViewProject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_gravity="center_vertical"
android:textColor="#FFFFFF"
android:textSize="23sp"
/>
</LinearLayout>
我想如果我通过代码添加背景应该可以工作,但我想知道这里有什么问题,为什么在 Android 4.3 上没有显示背景?先感谢您。
编辑:我尝试从 .png 和 .xml 文件中分配背景,但仍然没有显示。另外,我发现目前这个问题只发生在 Galaxy Nexus 上,当我在运行 Android 4.3 的 Galaxy S3 上进行测试时,一切都很好。
编辑2:现在问题自行消失了,如果有什么值得注意的事情发生,我会密切关注并写下
【问题讨论】:
-
您是否在所有可绘制文件夹中添加了 greenstripe.xml
-
是的,它就在那里,还有所有其他资源。在我测试过的其他设备上看起来还不错。只有在运行 Android 4.3 的设备上它才会消失
-
等等!它不是 .xml,而是 .png
-
无论如何,如果我创建一个 greenstripe.xml 使用它而不是 .png 也没关系,LinearLayout 背景仍然没有出现在 4.3
-
您是否使用了分辨率非常高的图像?
标签: android android-4.3-jelly-bean xml-layout