Listview Scrolling Using Universalimagedownloader Not Smooth
Solution 1:
I had the same issue with image downloading. I solved it by setting delayBeforeLoading(1000) in my DisplayImageOptions. It is needed to start downloading when user stop fling.
so try to replace your getDisplayOptions method with this
publicstatic DisplayImageOptions getDisplayOptions() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.drawable.error)
.showImageOnFail(R.drawable.error)
.delayBeforeLoading(1000)
.resetViewBeforeLoading(false) // default
.cacheInMemory(true) // default
.cacheOnDisc(true) // default
.build();
return options;
}
Documentation also recommends to use this code to avoid grid/list view scroll lags
booleanpauseOnScroll=false; // or truebooleanpauseOnFling=true; // or falsePauseOnScrollListenerlistener=newPauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling);
listView.setOnScrollListener(listener);
You can read it here (the last item of "Useful Info" list)
So you can use one of this methods
Solution 2:
@Sergey Pekar: You saved my life! :) I always used UIL for ListView for a small count of images, but then as the count got bigger I got always a lag on the first load (while scrolling) of the images. So I also tried the delay and it helped a little bit and other UIL configs and options, but I was not happy. Then I've tried different Image-Loading-Libraries (Picasso, AQuery, Volley, UrlImageViewHelper, custom code). They all worked faster(on first load) than UIL but they did not have enough options for me. So I looked for the last 2 days for a solution regarding this lag-problem and thanx god I finally found your post here! The solution was the PauseOnScrollListener!
What also (addtionally to the PauseOnScrollListener) improves a little bit the scroll-smoothness is by extending the ImageView to stop requestLayout like this:
publicclassCustomImageViewextendsImageView
{
publicCustomImageView(Context context, AttributeSet attributeset, int int_style)
{
super(context, attributeset, int_style);
}
publicCustomImageView(Context context, AttributeSet attributeset)
{
super(context, attributeset);
}
publicCustomImageView(Context context)
{
super(context);
}
@OverridepublicvoidrequestLayout()
{
// Do nothing here
}
}
For more info see this post: ListView very slow when scrolling (using ViewHolder/recycling)
Post a Comment for "Listview Scrolling Using Universalimagedownloader Not Smooth"