ImageView默认是不进行图片资源的回收的,需要我们自己在activity或者fragment中进行回收:
public static void releaseImageViewResouce(ImageView imageView) { if (imageView == null) return; Drawable drawable = imageView.getDrawable(); if (drawable != null && drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; Bitmap bitmap = bitmapDrawable.getBitmap(); if (bitmap != null && !bitmap.isRecycled()) { bitmap.recycle(); } } }
时间: 2024-10-17 06:55:53