简体   繁体   中英

Image sizes for various screen density/sizes : best practice

I'm almost at the end of the dev of an app, and for now, I've put every image I use (whether it's icons, buttons, or photos) in 4 sizes.

For example let's say I've got a photo that I want to be 300x120dp, I've put:

  • the photo with a 300x120px resolution in drawable-mdpi
  • the photo with a 450x180px resolution in drawable-hdpi
  • the photo with a 600x240px resolution in drawable-xdpi
  • the photo with a 900x360px resolution in drawable-xxdpi

First question: is it the best practice? Even for rather large photos? Just to be sure I understand: why can't we put a 900x360px photo in drawable folder and set the size in dp in the layout so that the image is scaled down on small screen densities? For memory optimization?

Most importantly, I'm now working on layouts for 7 inches and 10 inches tablets. Let's take the same image of 300x120dp. This image is too small for a 10 inches tablet, and so I would like it to be 600x240dp on that screen size. What must I do? Generate 4 new images? If yes, let's say all my images are 2 times larger on a 10 inches tablet, must I generate 4 new images for all the images? And 4 new images for the 7 inches layouts?

Many thanks for your advices.

If you have a photo (just photo, not graphic with sharp edges like icons and so on!) -- practically there is no need to make it for xxhdpi, or even xhdpi, pixels there are not recognizable by eye. And make devices with medium resolution downsample hi-res pictures is bad practice, because often such devices have memory limits. Remember that image in mdpi is 4 times lighter than xhdpi and 9 times lighter than xxhdpi.

So, for photos (not icons and ui elements!): mdpi, hdpi, both for phones and tablets, will be enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM