RecyclerView laggy scrolling

后端 未结 13 737
闹比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:35

    In my case, bitmap creation was making delay for scroll. So I put bitmap creation in background thread and set to image in UI thread. This way, UI is not blocked for bitmap creation

    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            Bitmap myBitmap = BitmapFactory.decodeFile(filepath);
                            activity.runOnUiThread(new Runnable() {
                                public void run() {
                                    vItem.imgProfile.setImageBitmap(myBitmap);
               
                                }
                            });
                        }
                    }).start();
    
    0 讨论(0)
提交回复
热议问题