Extremely Laggy RecyclerView Performance

前端 未结 2 1702
时光说笑
时光说笑 2021-01-18 03:41

I have a RecyclerView implementation inside of a ViewPager, and its performance is pretty horrible. Here\'s a video of the performance in question.

相关标签:
2条回答
  • 2021-01-18 03:55

    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.

    0 讨论(0)
  • 2021-01-18 04:07

    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.

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