When I put the image in drawable folder, I get OutOfMemoryError while setting the image resource, but after moving the same image to drawable-nodpi folder that error is resolved. How is error resolved on moving the image to drawable-nodpi folder?
res/drawable/ is a legacy synonym for res/drawable-mdpi/, indicating that the drawables in that directory are set for mdpi density. If the device is running another density, those images will be downsampled (to ldpi) or upsampled (to anything else) to match the device density.
res/drawable-nodpi/ says "these drawables should not be resampled for any density, but instead should be used as-is on all densities".
If you are getting an OutOfMemoryError that clears up when you move the image to res/drawable-nodpi/, that indicates two things:
The image is probably too large to begin with
Upsampling the image to a higher density failed, because there was no block of memory big enough for the larger upsampled image
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With