不理解如何使用不同的密度图像为1.6+如何使用、不理解、密度、图像

2023-09-04 04:30:07 作者:残年

我想明白是怎么RES /可绘制的图像应该与不同的屏幕密度。现在我有一个1.5的应用程序的,例如我有一个形象,是100×100像素。当在Droid使用它,因此它似乎是相同的尺寸相对于该设备(所有其它布局换算由箱处理,用浸单位)。

I'm trying to understand how the res/drawables images should work with different screen densities. Right now I've got a 1.5 app, and for example I have an image that is 100x100 pixels. When used on the Droid, it scales this image so it appears to be the same size relatively on that device (all other layout scaling is handled by me, using dip units).

所以,现在我需要更新我的项目,并添加三个文件夹,右:?

So now I need to update my project and add three folders, right?:

绘制-LDPI 绘制-MDPI 绘制 - 华电国际

所以我打算把我的100×100图像中的-mdpi文件夹。如果我想打一个版本的-hdpi文件夹 - 我怎么知道有多少大通过规模呢?我的意思是它看起来像在默认情况下,应1.5倍大。但是,如果我让2.0X大,或者我上运行的设备不正好有一个密度1.5倍的基准G1会发生什么?会不会我的布局开始寻找在这些设备上有什么不同?

so I'm going to put my 100x100 image in the -mdpi folder. If I want to make a version for the -hdpi folder - how do I know how much larger to scale it by? I mean it looks like by default it should be 1.5x bigger. But what happens if I make it 2.0x bigger, or the device I'm running on doesn't happen to have a density 1.5x that of the baseline G1? Won't my layouts start looking different on those devices?

感谢

推荐答案

LDPI,MDPI和HDPI对应密度类,该装置的不实际密度

ldpi, mdpi, and hdpi correspond to density "classes", not the actual density of the device.

有关实例中的G1是一个MDPI类设备(160dpi),但其屏幕像素密度实际上是围绕180dpi。该机器人是华电国际一流的设备(240dpi),但它的屏幕为265dpi。

For instance the G1 is a mdpi class device (160dpi) but its screen density is actually around 180dpi. The droid is a hdpi class device (240dpi) but its screen is 265dpi.

位图缩放仅基于密度类。实际的屏幕像素密度将被忽略。

Bitmap scaling is based on the density class only. The actual screen density is ignored.

因此​​,一个G1将显示MDPI位图比真正的160dpi屏幕MDPI设备略小,但是这是一个非常小的差异,所以它不是一个大问题。

So a G1 will show mdpi bitmaps slightly smaller than a mdpi device with a true 160dpi screen, but this is a very small difference so it's not a big deal.

(注意,其它类型的维,如在和毫米,不考虑在屏幕密度。)

(Note that other dimension types, such as "in" and "mm", do take into account the screen density.)

因此​​,对于密度你有3个选择:LDPI(120),MDPI(160)和HDPI(240)。因此,您的100×100的位图应该是75x75,100×100,150×150和分别。

So for densities you have 3 choices: ldpi (120), mdpi (160) and hdpi (240). Therefore, your 100x100 bitmap should be 75x75, 100x100, and 150x150 respectively.

有关详细信息,请参阅:http://developer.android.com/guide/practices/screens%5Fsupport.html#qualifiers

For more info see: http://developer.android.com/guide/practices/screens%5Fsupport.html#qualifiers