Android png images big in memory

后端 未结 2 1820
北荒
北荒 2020-12-20 07:29

I have an application in android that has an imageflipper. Problem is, after about 8 images loaded to memory, I get an out of memory error.

Well, I tried to do dyna

2条回答
  •  旧时难觅i
    2020-12-20 08:28

    Use BitmapFactory.Options

    BitmapFactory.Options opts = new BitmapFactory.Options();
    opt.inSampleSize = 2;
    //this will decrease bitmap size,
    // but also affect quality of the image, 
    //so just play with this value to spot the good one;
    Bitmap b = BitmapFactory.decodeFile(fileName, opts);
    

提交回复
热议问题