我的代碼如下
is = new FileInputStream(new File(baseMagazinePath + this.bookId + "/" + fileList[currentImgNo] + ".png"));
iv.setImageDrawable(Drawable.createFromStream(is, "myStream"));
有時候出現內存溢出
改爲
is = new FileInputStream(new File(baseMagazinePath + this.bookId + "/" + fileList[currentImgNo] + ".png"));
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeStream(is, null, opts);
iv.setImageBitmap(bitmap);
就好了。