RecyclerView laggy scrolling

后端 未结 13 735
闹比i
闹比i 2020-12-09 09:44

I am loading 400x200 images in RecyclerView, but scrolling is laggy on 2k devices. I am using Picasso for loading images from resource.

As you can see in the demo ima

相关标签:
13条回答
  • 2020-12-09 10:09

    I am bit late but this can be fixed bu using thumbnail with Glide.

         Glide.with(context)
                    .load(URL)
                    .dontAnimate()
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .thumbnail(0.5f)
                    .centerCrop()
                    .into(imageView);
    
    0 讨论(0)
  • 2020-12-09 10:13

    I think the reason is that Picasso caches your images but since you have a list of drawables that you bundle together with your app, you do not in theory need to cache your images. Caching is only useful when you are downloading the image from the internet and you don't want the app to redownload the images each time you swipe up or down on the recyclerview.

    I would adjust the way picasso works by changing the memorypolicy so try this instead :

     Picasso.with(getContext()).load(data.get(pos).getFeed_thumb_image()).memoryPolicy(MemoryPolicy.NO_CACHE).into(image);
    
    0 讨论(0)
  • 2020-12-09 10:18

    This could be because of Picasso taking time to load the image. Use the below snapshot and adjust accordingly.

    Picasso.with (context)
                        .load (url).fit().centerCrop()
                        .error (R.drawable.UserImage)         
                        .into (imageView);
    

    Use fit() and centerCrop() to avoid legginess.

    0 讨论(0)
  • 2020-12-09 10:20

    I had laggy recyclerView issue when one of the textView within the recyclerView was receiving null values. I fix this and my recyclerView stopped lagging.

    0 讨论(0)
  • 2020-12-09 10:20

    It might be late, but maybe somebody will find it useful. Had the same problem, problem was at line:

    Picasso.get().load(image).into(holder.imageView); 
    

    so I added fit().centerCrop() like this:

    Picasso.get().load(image).fit().centerCrop().into(holder.imageView);
    

    That solved my problem

    0 讨论(0)
  • 2020-12-09 10:23

    if you use Recyclerview in vertical mode and your activity contains other item that you have ScrollView then you must use NestedScrollView instead of ScrollView.

    as described in google documentation NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.

    0 讨论(0)
提交回复
热议问题