简体   繁体   中英

How to determine image size for various density?

I am developing for a Galaxy nexus 720P Phone. I have developed a background image to be exact 720P. But the image is been stretched. What should be the height and width of the image to not have it stretched on the phone ?

It depends on the Layout properties. If the imageview height is larger than the image you pass to the imageview, then the image will be streched. Set the imageview layout property layout_height="wrap_content" to not strech the image otherwise resize your image according to your phone height.

If you are developing specifically for the Galaxy nexus 720p, then your image should have the following dimensions: 1280 x 720

But you can't expect it to be properly displayed on all devices...

Take a look at this:

http://developer.android.com/guide/practices/screens_support.html

尝试看一下draw9patch,它是Google的用于调整图像大小的工具:D

basically 3 densities are available 120 dpi (1 dp = 0.75 px) 160 dpi (1 dp = 1 px) 240 dpi (1 dp = 1.5 px)

px - pixel dp - dots per inch

Check the dpi of your target device and create images according to the area you want to cover.

Eg: if the device is medium density(160) and you want to cover 720 dp create 720 px image if device is high density(240) and you want to cover 720 dp 1080 px.

This will help you while creating images for devices with other configurations.

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