【问题标题】:Android listView really slow with background ImageAndroid listView 的背景图片真的很慢
【发布时间】: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


【解决方案1】:

如果它只是一个白色背景,那么看看你是否可以将背景颜色设置为白色而不是使用可绘制对象。事情会立即加速!

【讨论】:

  • 我知道,但我需要为我的所有活动窗口提供图像背景,除此之外还有一个列表视图。实际上这不应该影响列表视图的性能,因为完整的列表视图具有白色背景。
  • 您是否使用自定义适配器来进行列表视图?
猜你喜欢
  • 1970-01-01
  • 2015-09-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多