I have a RecyclerView
implementation inside of a ViewPager
, and its performance is pretty horrible. Here\'s a video of the performance in question.
I was having the same problem with RecyclerView. It was laggy. In my case, there was a horizontal list of image buttons inside RecyclerView.
I solved it by removing the scaleType
from ImageButtons
or ImageViews
and loading images through Picasso with resizing
like :
Picasso.with(context).load(icon.get(position)).resize(270,270).centerCrop().into(holder.iconView);
The problem of lag may occur due to runtime scaling of big sized images or no. of images. It is not advisable. Whereas Picasso takes care of resizing, and loading efficiently. Also it handles caching for you.
I used the same line of code written by TheOddAbhi, I mean
Picasso.with(context).load(icon.get(position)).resize(270,270).centerCrop().into(holder.iconView);
But in my layout file removing the scaleType
from my ImageView
didn't work, so I removed android:adjustViewBounds="true"
, which was the problem causing lagging.