Extremely Laggy RecyclerView Performance

前端 未结 2 1701
时光说笑
时光说笑 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.

提交回复
热议问题