我有以下布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="@drawable/1dot6_mb_bitmap">
<include layout="@layout/top_bar"/>
<LinearLayout
android:id="@+id/layout_2"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:orientation="vertical">
<ListView
android:id="@+id/layout_3"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</LinearLayout>
<include layout="@layout/bottom_bar"/>
当我将大位图设置为layout_1容器的背景时,ListView滚动非常慢。如果我从背景中删除图像,ListView 就会完美滚动。我也尝试过使用 ScrollView,它的行为是相同的。 我无法使用重复图像或 9.png,因为大图像实际上是风景照片。 你知道我该如何解决这个问题吗?或者在这种情况下 ListView/ScrollView 表现如此缓慢的原因是什么?
谢谢
最佳答案
假设图像大于其占用的空间,您可以将其加载到成员中,使用 BitmapFactory类在将图像插入布局之前调整图像大小。
关于java - ListView/ScrollViews 下的大位图会减慢滚动速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7203634/