【发布时间】:2012-10-06 13:59:51
【问题描述】:
我有以下问题:我正在使用带有主题背景图像的常规 ListView,这给我带来了很大的性能问题。当我删除窗口(请参阅themes.xml)背景图像时,一切都很顺利。使用背景图片会明显变慢。
我已经试过了:
- android:cacheColorHint="#00000000"
- listview.setScrollingCacheEnabled(false);
但没有任何效果。我不明白为什么这么慢,因为 ListView 只是纯白色 - 应该不是问题......
主题.xml:
<item name="android:windowBackground">@drawable/window_bg</item>
list.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp">
<ListView
android:id="@+id/my_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"/>
</RelativeLayout>
【问题讨论】:
-
您是为每个列表项(在自定义适配器中)还是将背景应用到整个列表视图?
-
目前我为每个列表项设置了背景颜色。我在列表项中删除了它,因为它是不必要的,但仍然存在相同的性能问题
标签: android performance listview background-image