0

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 Answers1

0
  1. When user with mdpi device screen starts your program - program will get images from mdpi folder of resources. If you have only xhdpi images - on his mdpi device system will downscale image from xhdpi folder 2 times before showing. If image exist only in mdpi folder - on xhdpi 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 docs

  2. If 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 for mdpi users will be much smaller than .apk files for xxhdpi users.

ashakirov
  • 12,112
  • 6
  • 40
  • 40