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
mdpidevice screen starts your program - program will get images frommdpifolder of resources. If you have onlyxhdpiimages - on hismdpidevice system will downscale image fromxhdpifolder 2 times before showing. If image exist only inmdpifolder - onxhdpidevice 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
.apksize for user. When you upload.aabfile (Android App Bundle) to google play (instead of.apk) and user installs your app he will download.apkfile which contains images only for his density (image copies for other denseties will be removed from apk). It means that apk files formdpiusers will be much smaller than.apkfiles forxxhdpiusers.
- 12,112
- 6
- 40
- 40