6

出于某种原因,每当我滚动浏览我的项目列表时,我的列表视图中的背景都会消失并重新出现,从而产生我并不真正想要的“闪烁”效果。我已经尝试过以下建议:如何在 Android 中使 ListView 透明?但由于某种原因它不起作用。有什么建议么?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/screenLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:background="@color/title_background"
            android:text="@string/whatsnew_title"
            >
        </TextView>
        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >
        </ListView>     
</LinearLayout>
4

3 回答 3

21

你包括了android:cacheColorHint="#00000000"吗?这是建议修复中最重要的部分。我刚刚尝试了您的代码(显然不是精确复制,因为您使用的是对项目特定资源的引用),它似乎有效。

您应该对 Android 开发者博客上的这篇文章感兴趣。

于 2009-10-09T02:27:36.660 回答
2

这也可以从 Java(代码)端实现:listView.setCacheColorHint(Color.TRANSPARENT);

于 2012-10-09T20:56:12.897 回答
1

检查您的 theme.xml 中的<item name="android:windowBackground">@null</item>. 如果你有 - 删除它。我认为流行的资源之一以这条线为例(这就是我得到我的方式)。

于 2009-10-08T03:38:54.613 回答