OiO.lk Blog Android Is it better to store multiple image sizes in drawable directories or just a single large image in assets for Android apps?
Android

Is it better to store multiple image sizes in drawable directories or just a single large image in assets for Android apps?


I’m developing a native Android app and am considering the best way to manage image resources. Traditionally, we’ve been advised to store multiple sizes of each image in various drawable folders (drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi, and drawable-xxxhdpi) to match different device screen densities. However, I’m questioning whether this approach is still relevant or necessary today.

Given advancements in Android’s handling of images and screen densities, is it more efficient or advantageous to store just a single, high-resolution image (e.g., a 400×400 image for an originally 100×100 image) in the assets folder and resize it dynamically in the app based on the device’s screen density?

For example, for an image initially meant to be 100×100:

Traditionally, I would store these variants:

drawable-mdpi = 100x100
drawable-hdpi = 150x150
drawable-xhdpi = 200x200
drawable-xxhdpi = 300x300
drawable-xxxhdpi = 400x400

However, on a device like the Google Pixel 7 with a screen density factor of 2.625, the system retrieves the 300×300 image from drawable-xxhdpi and then resizes it to 263x263px. This results in the image being resized twice, potentially degrading its quality.

I’ve noticed that many apps seem to store their images mainly in the assets folder rather than in the drawable directories. Can anyone confirm if this is a common practice? What is the recommended approach in 2024 for handling images in Android apps to balance between image quality and app performance?



You need to sign in to view this answers

Exit mobile version