繁体   English   中英

Galaxy Nexus上未显示线性布局背景

[英]Linear Layout background not shown on Galaxy Nexus

我有一个使用列表视图显示信息的应用程序,并且放置了部分来划分不同类型的数据。 这是一个截图,它在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:现在问题已自行消失,我将继续关注并在发生重大变化时写信

我有同样的问题 :

  • 具有白色背景的ListView
  • 每个孩子的RelativeLayout中都有一个背景为灰色且宽度和高度为match_parent的View

在API 17上,一切正常

在API 18+上,ListView是白色的

我没有设置固定的高度,而是在视图中放置了一个min_height,问题得到了解决(临时)!

希望能帮助到你

我认为这是您的观点的循环利用问题。 您需要在适配器的getView()方法中重置背景。 如果需要更多帮助,请复制/粘贴您的适配器代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM