Skip to content Skip to sidebar Skip to footer

Recyclerview Laggy Scrolling

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 images are blurry

Solution 1:

if you are using two or more recycler views like (RecyclerView and NestedView) try this

recyclerView.setNestedScrollingEnabled(false);

Source : Recyclerview inside Nested Scrollview scroll but does not fast scroll like normal Recyclerview or Nested Scrollview

Solution 2:

Is RecyclerView.setHasFixedSize() set to true? I'm not able to reproduce this lag...can you please post the whole project on git? Check this out, maybe it can help you: http://antonioleiva.com/recyclerview/

Solution 3:

I Believe that sometimes you may piss off when only trying some static images in drawable to display your recycler view. And it happens extremely lagging.

Why? You may not get this issue when using some library to load an image from url (Picasso, Glide, ...), but what happens with the same image, the same size, and it's right in your drawable (not need to download at all). And after a while, I figure out, android did some trick to resize an image in drawable for us to get a proper image in different resolution devices. So my suggestion is to use drawable-nodpi to store your image in order for android not to interfere with our images.

Solution 4:

This is because the image is taking time to load. Firstly, change your code for loading image as the below one...

Picasso.get().load(list.get(position).id).fit().centerCrop()
                .placeholder(R.drawable.ic_launcher)
                .into(holder.cardimage);

Then, before setting the adapter on recyclerview to the instance of CardAdapter inside MainActivity add this line..

        yourAdapter_name.setHasStableIds(true);

One more tip...If anyone is using large drawables (xxxhdpi, xxhdpi ), first convert them into mdpi or ldpi . This will also improve the performance a lot and also reduces the apk size.You can use this website NativeScript Image Builder

Solution 5:

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.

Post a Comment for "Recyclerview Laggy Scrolling"