【问题标题】:Android: ListView xml layout not showing background image when scrolledAndroid:滚动时ListView xml布局不显示背景图像
【发布时间】:2012-06-28 12:21:09
【问题描述】:

我有一个带有 ListView 的 Activity,我以编程方式将背景图像设置为视图。 当我向下滚动列表时,背景图像变为白色(因为我的主题是 Theme.Light.NoTitleBar)。

  1. 我怎样才能让它在蓝色背景完好无损的情况下滚动?
  2. 如果上述方法有效,如何将 ListView 的文本颜色改为白色而不是黑色?

普通列表视图

滚动列表视图

按下 ListView 项目

【问题讨论】:

    标签: android listview scroll background-image listitem


    【解决方案1】:
    1. 在ListView标签中使用属性android:cacheColorHint="#000000"
    2. 关于使TextView's颜色为黑色或白色,您可以refer here为您的ListView行自定义TextView,您要做的额外工作就是在TextView标签内添加另一个属性,例如这个

      android:textColor="#FFF" //or #FFFFFF for white

    【讨论】:

    • 唯一能回答我两个问题的答案,非常感谢:)
    【解决方案2】:

    在 ListView 标签上添加一个属性

    android:cacheColorHint="#00000000"// setting as a transparent color
    

    【讨论】:

      【解决方案3】:

      这是由于优化所致。要删除它,只需将 listView 的 cacheColorHint 设置为透明,如下所示:android:cacheColorHint="#00000000"

      全文在这里:http://android-developers.blogspot.fr/2009/01/why-is-my-list-black-android.html

      【讨论】:

        【解决方案4】:

        您可以将 ListView 包裹在具有相同背景的 LinearLayout 上,然后删除 ListView 的 Background应该可以正常工作。 :)

        【讨论】:

        • 这是解决方法而不是解决方案,我不认为我应该为这个答案投票。
        【解决方案5】:

        请查看this答案。我遇到了同样的问题,可以通过在适配器端放置 view = null 来解决。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-04-16
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-02-17
          • 2012-04-18
          相关资源
          最近更新 更多