ListView scrolling using UniversalImageDownloader not smooth

后端 未结 2 1334
星月不相逢
星月不相逢 2021-02-10 13:58

I am using a ListView containing images. These images are loaded from the Internet inside the adapter. Therefore I am using the UniversalImageDownloader.

<
2条回答
  •  灰色年华
    2021-02-10 14:46

    @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:

    public class CustomImageView extends ImageView
    {
        public CustomImageView (Context context, AttributeSet attributeset, int int_style)
        {
            super(context, attributeset, int_style);
        }
    
        public CustomImageView (Context context, AttributeSet attributeset)
        {
            super(context, attributeset);
        }
    
        public CustomImageView (Context context)
        {
            super(context);
        }
    
        @Override
        public void requestLayout() 
        {
            // Do nothing here
        }
    }
    

    For more info see this post:
    ListView very slow when scrolling (using ViewHolder/recycling)

提交回复
热议问题