ImageViews changed positions when scrolling in GridView

☆樱花仙子☆ 提交于 2019-12-08 19:02:29

Loader needed some time to load picure in ImageView. Because you reuse view for different images you can see a previous image in the view while new image is loading. You can set resetViewBeforeLoading(true) in DisplayImageOptions for avoid this effect.

Also you can use disk cache to avoid downloading images every time from the network. Also limit size of memory cache and set other settings, but I think memory cache is useful, it improves user experience. And don't forget to use setOnScrollListener(new PauseOnScrollListener(loader, true, true)) to avoid lags on scrolling.

GridView recycles list items for performance purposes. So when you are scrolling, the list items are getting recycled in different places and then your code is re-populating them. Sometimes this lags for images.

I'd recommend using a library that handles this sort of thing like Picasso.

I was having the exactly same problem as you, and didn't want to disable convertView checking either. My solution was to increase the memory cache size in ImageLoaderConfiguration.

Before, i used to use it like this: .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))

So I changed it to: .memoryCache(new UsingFreqLimitedMemoryCache(10 * 1024 * 1024))

I don't know if 10*1024*1024 is too much or it will cause any problems, but it seems to have fixed the problem to me and i haven't had any problems until now.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!