简体   繁体   English

如何确定各种密度的图像尺寸?

[英]How to determine image size for various density?

I am developing for a Galaxy nexus 720P Phone. 我正在开发Galaxy nexus 720P电话。 I have developed a background image to be exact 720P. 我已经开发了精确到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. 如果imageview高度大于传递给imageview的图像,则该图像将被拉伸。 Set the imageview layout property layout_height="wrap_content" to not strech the image otherwise resize your image according to your phone height. 设置imageview布局属性layout_height =“ wrap_content”以不拉伸图像,否则根据手机高度调整图像大小。

If you are developing specifically for the Galaxy nexus 720p, then your image should have the following dimensions: 1280 x 720 如果您是专门为Galaxy nexus 720p开发的,则图像应具有以下尺寸: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 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) 基本上有3种密度可用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 px-像素dp-每英寸点数

Check the dpi of your target device and create images according to the area you want to cover. 检查目标设备的dpi,然后根据要覆盖的区域创建图像。

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. 例如:如果设备是中等密度(160),并且您想覆盖720 dp,则如果设备是高密度(240),并且想要覆盖720 dp,则需要创建720 px图像。

This will help you while creating images for devices with other configurations. 这将为使用其他配置的设备创建映像时提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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