简体   繁体   English

Android图像尺寸最佳做法

[英]Android image sizes best practises

I read this tutorial http://developer.android.com/guide/practices/screens_support.html#DeclaringTabletLayouts ,but I don't understand all examples.I want to create an image in my android application ,but I don't know how much pixels should I use,for example in drawable-ldpi , drawable-mdpi , drawable-hdpi and drawable-hxdpi which sizes I should use ? 我阅读了本教程http://developer.android.com/guide/practices/screens_support.html#DeclaringTabletLayouts ,但是我不理解所有示例。我想在我的android应用程序中创建图片,但我不知道我应该使用多少像素,例如在drawable-ldpi,drawable-mdpi,drawable-hdpi和drawable-hxdpi中应使用哪些尺寸? What means 3:4:6:8 sizes ?Is this for images or for application Icon ? 3:4:6:8尺寸是什么意思?这是用于图像还是用于应用程序图标?

Have a look to the Android documentation: 看看Android文档:

http://developer.android.com/design/style/iconography.html http://developer.android.com/design/style/iconography.html

They explain what you are asking at the beginning, but I advise you to read the whole article. 他们一开始会解释您的要求,但我建议您阅读全文。

If you want to generate an icon set with all the different dimensions wanted, you can use a tool named Icon Generator that you can find here: 如果要生成具有所需所有不同尺寸的图标集,则可以使用名为Icon Generator的工具,可以在以下位置找到:

http://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-launcher.html http://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-launcher.html

This tool is also available if you are using Eclipse to develop: 如果您正在使用Eclipse进行开发,则该工具也可用:

  • Right-click on the Android project 右键单击Android项目
  • New --> Other ... 新增->其他...
  • Then open the Android folder and select "Android Icon Set" 然后打开Android文件夹并选择“ Android图标集”

Then just follow the steps to create the icons wanted, they will be automatically added in your project in your "res" folder. 然后,只需按照以下步骤创建所需的图标,它们就会自动添加到您的项目的“ res”文件夹中。

Concerning the image sizes, I advise you to use "dp": 关于图像大小,我建议您使用“ dp”:

The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen. 与密度无关的像素等效于160 dpi屏幕上的一个物理像素,这是系统为“中”密度屏幕假定的基线密度。 At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. 在运行时,系统会根据使用中屏幕的实际密度,根据需要透明地处理dp单位的任何缩放比例。 The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). dp单位到屏幕像素的转换很简单:px = dp *(dpi / 160)。 For example, on a 240 dpi screen, 1 dp equals 1.5 physical pixels. 例如,在240 dpi屏幕上,1 dp等于1.5物理像素。 You should always use dp units when defining your application's UI, to ensure proper display of your UI on screens with different densities. 定义应用程序的UI时,应始终使用dp单位,以确保在具有不同密度的屏幕上正确显示UI。

Several links on the official doc: 官方文档上的几个链接:

http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/training/multiscreen/screendensities.html http://developer.android.com/design/style/metrics-grids.html http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/training/multiscreen/screendensities.html http://developer.android.com/design/style/metrics- grids.html

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

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