During Development I was importing images for different screen sizes like mdpi, hdpi, xxhdpi, xxxhdpi etc. I had to give image a fixed sized like 240dp x 80dp. then what is the role of importing images of different screen size if I am giving fixed value. it is better if I will import one image with good resolution then use fixed value. please clear my concept if I am wrong
-
1"what is the role of importing images of different screen size" -- `mdpi`, `hdpi`, `xxhdpi`, and `xxxhdpi` are screen *densities*, not screen *sizes*. See [the documentation](https://developer.android.com/training/multiscreen/screendensities) for more. – CommonsWare Oct 24 '20 at 11:43
-
that I already know. Read the question carefully I added a condition that if i am using fixed dp ..if the density is decided which is fixed then why importing dynamic images – Parikshit Sharma Oct 24 '20 at 14:50
-
"I added a condition that if i am using fixed dp" -- you are using a fixed *size*. "if the density is decided which is fixed" -- you are using a fixed *size*. `240dp` and `80dp` are *sizes* measured in density-independent pixels (`dp`). Please read [the documentation](https://developer.android.com/training/multiscreen/screendensities). – CommonsWare Oct 24 '20 at 14:55
1 Answers
When user with
mdpi
device screen starts your program - program will get images frommdpi
folder of resources. If you have onlyxhdpi
images - on hismdpi
device system will downscale image fromxhdpi
folder 2 times before showing. If image exist only inmdpi
folder - onxhdpi
device image will upscale 2 times before showing. Downscaling/upscaling means extra CPU, memory usage and lower performance. When you provide image for all densities system will just show proper image without extra calculations. Check scale coeficients here and link to docsIf you provide image for all densities there is also profit in
.apk
size for user. When you upload.aab
file (Android App Bundle) to google play (instead of.apk
) and user installs your app he will download.apk
file which contains images only for his density (image copies for other denseties will be removed from apk). It means that apk files formdpi
users will be much smaller than.apk
files forxxhdpi
users.

- 12,112
- 6
- 40
- 40