简体   繁体   中英

Android - Resource Bitmap uses more memory than Bitmap from file

I noticed something odd. If I open an image (1.6mb) from Drawable Resource, the app crashes with the OutOfMemory error, however, if I open the same image which is saved on SD Card, the app does not crash.

What is the effect of the two?

Solution:

Place images in /drawable-nodpi folder and not /drawable

Cause:

pictures in "/drawable" generic folder are considered by the system like "/drawable/mdpi". So the images are resized when used by the system, causing the OutOfMemory error.

check this out :

I had all the pictures in "/drawable" generic folder that is considered by the system like "/drawable/mdpi", so when I were running in devices with hdpi or more the images were resized, and became too big which cause OutOfMemoryException!

from: Android setBackgroundResource cause out of memory excepiton

you think this might be your case?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM