RecyclerView blinking after notifyDatasetChanged()

前端 未结 18 1745
悲&欢浪女
悲&欢浪女 2020-12-07 16:20

I have a RecyclerView which loads some data from API, includes an image url and some data, and I use networkImageView to lazy load image.

@Override
public vo         


        
18条回答
  •  旧时难觅i
    2020-12-07 16:48

    I had similar issue and this worked for me You can call this method to set size for image cache

    private int getCacheSize(Context context) {
    
        final DisplayMetrics displayMetrics = context.getResources().
                getDisplayMetrics();
        final int screenWidth = displayMetrics.widthPixels;
        final int screenHeight = displayMetrics.heightPixels;
        // 4 bytes per pixel
        final int screenBytes = screenWidth * screenHeight * 4;
    
        return screenBytes * 3;
    }
    

提交回复
热议问题