使用Picasso加载大图片速度缓慢

5
我正在使用Picasso将大小约为250-500 KB(1600x~1200)的JPG文件从Url加载到ImageView中。
Picasso.with(getApplicationContext())
.load(stringURL)                        
.placeholder(R.drawable.holder).error(R.drawable.holder)
.into(image)

我的ImageView:

<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_marginTop="0dip"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:scaleType="fitCenter" 

问题在于图片的首次加载非常慢(大约20秒),CPU消耗高,因此内存分配也很大。 例如,LogCat显示“Grow heap (frag case) to 56.789 for 7601812-byte allocation”仅针对单个图像。

这是否与图像缓存有关?有没有一种方法可以禁用缓存并直接将原始图像下载到ImageView中?

从iPhone中的双子应用程序下载相同的图像是瞬间完成的...


那是一个7MB的图像。根据你的日志,1600x1200x4=7.6MB。这需要时间来解码。尝试使用fit()resize(),或者在最后使用你的RGB_565配置。 - dnkoutso
2个回答

3
如果您使用 fit()resize(),那么这应该可以解决您的问题。我目前将数百个非常大的jpg文件加载到单个GridLayout中,并且没有任何问题。

1

我转向使用Volley。现在加载相同的图片只需要很短的时间。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接