码迷,mamicode.com
首页 > 移动开发 > 详细

[Android Memory] 手动回收ImageVIew的图片资源

时间:2014-09-03 19:48:37      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   color   div   cti   sp   log   amp   

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();
            }
        }
    }

 

[Android Memory] 手动回收ImageVIew的图片资源

标签:android   style   blog   color   div   cti   sp   log   amp   

原文地址:http://www.cnblogs.com/0616--ataozhijia/p/3954402.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!