无法理解如何为1.6+使用不同密度的图像? [英] Not able to understand how to use different density images for 1.6+?

查看:92
本文介绍了无法理解如何为1.6+使用不同密度的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解res/drawables图像应如何在不同的屏幕密度下工作.现在我有一个1.5应用程序,例如,我有一个100x100像素的图像.在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?:

  1. drawable-ldpi
  2. drawable-mdpi
  3. drawable-hdpi

所以我要把我的100x100图像放在-mdpi文件夹中.如果我想为-hdpi文件夹创建一个版本-我怎么知道缩放它的大小?我的意思是默认情况下看起来应该大1.5倍.但是,如果我将其增大2.0倍,或者正在运行的设备的密度恰好不是基准G1的1.5倍,会发生什么?在这些设备上,布局不会开始看起来有所不同吗?

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.机器人是hdpi类设备(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.

(请注意,其他尺寸类型,例如"in"和"mm",确实考虑了屏幕密度.)

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

因此对于密度,您可以选择3种:ldpi(120),mdpi(160)和hdpi(240).因此,您的100x100位图应分别为75x75、100x100和150x150.

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_support.html#qualifiers

For more info see: http://developer.android.com/guide/practices/screens_support.html#qualifiers

这篇关于无法理解如何为1.6+使用不同密度的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆