ImageView cannot display high resolution images
I am accessing images from android resource folder. I am using asynctask to load images.
The first time I used images with a resolution of 1024 * 768, the application opens and the image is displayed one image at a time.
Second time, For experiment, I used images with 1920 * 1080 resolution, application gives runtime error and forcibly closes. The same happens with an image resolution of 1280 * 720.
but it works with 1024 * 768 resolution why is this happening ????
I am not posting the code because it has no programming problem.
source to share
You just got it Out Of Memory exception
, because the image size is large, consider this calculation:
To show each pixel in ARGB_8888
, we use 4 bytes like so:
your first image: 1024 * 768 * 4 = 2MB
your second image: 1920 * 1080* 4 = 6MB
your third image: 1280 * 720 * 4 = 3MB
I don't know how many images you upload to RAM
yours but yours is RAM
limited and it is at least 16MB
so with other 4-5 images you won't have RAM
for other objects, take a look
Loading large bitmaps Effective to solve your problem.
source to share