彻底销毁imageview


首先根据你设置Imageview资源时候的方式,将资源重置为null
view.setImageBitmap(null);
//把iamgeview 的Drawable 释放掉 请求gc 清理内存垃圾
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();
        }
    }
    System.gc();
}

// 最后从view 容器中移除是放掉的view

container.removeView((View) object);

// 解释



你可能感兴趣的:(彻底销毁imageview)