[Android Memory] 手动回收ImageVIew的图片资源
时间:2014-09-03 19:48:37
收藏:0
阅读:566
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(); } } }
原文:http://www.cnblogs.com/0616--ataozhijia/p/3954402.html
评论(0)