I'm working on a tablet app. I tried to set high-resolution (2223x3553) images as background using Layout.setBackgroundResource(ResId)
. The app crashed while testing on Nexus 7
, I won't paste the stack traces since there were like 8 or 9 exceptions with about 300 red lines in the LogCat
and it took me a while to figure out the reason. I got it after I noticed the OutOfMemoryException
, using 1280x800 images the app runs fine but some quality loss has occurred since those images are designed to be high-res.
The question: how to handle high-resolution images in Android to prevent crashes like that? All images are local and stored in the drawable
folder
Image sizes are limited in android development. You can not use images which are bigger than the prescribed ones. There is a guideline about how to choose images for your application. This is the link to the guidelines.
You have to use same library that I have used in such a Use Case ,
This project will help you in yours also. Because you need to compress the images while displaying them and also use the capability of lazy loading if you need eventually.