1

通过支持不同的密度,有 4 种类型的屏幕:

xhdpi
hdpi
mdpi
ldpi

我想知道这些的确切屏幕尺寸(以像素为单位)是多少?:

normal-xhdpi                      large-xhdpi
normal-hdpi                       large-hdpi
normal-mdpi                       large-mdpi

这些屏幕尺寸由 Eclipse 给出:

xhdpi :    768 x 1280 
          2560 x 1600
           720 x 1280

hdpi :     480 x 800
           480 x 854

mdpi :    1280 x 800
          1024 x 600
           480 x 854
           480 x 800
           320 x 480

在此处输入图像描述

4

2 回答 2

2

看到你正在混合这些概念。small、medium、large 和 xlarge 是屏幕尺寸,而 ldpi、mdpi、hdpi、xhdpi、nodpi 和 tvdpi 是屏幕密度

根据Android 开发者的网站

尺寸

small   -   Resources for small size screens.
normal  -   Resources for normal size screens. (This is the baseline size.)
large   -   Resources for large size screens.
xlarge  -   Resources for extra large size screens.

密度

ldpi    Resources for low-density (ldpi) screens (~120dpi).
mdpi    Resources for medium-density (mdpi) screens (~160dpi). 
        (This is the baseline density.)

hdpi    Resources for high-density (hdpi) screens (~240dpi).
xhdpi   Resources for extra high-density (xhdpi) screens (~320dpi).
nodpi   Resources for all densities. These are density-independent resources. 
        The system does not scale resources tagged with this qualifier, 
        regardless of the current screen's density.
tvdpi   Resources for screens somewhere between mdpi and hdpi; approximately 
        213dpi. This is not considered a "primary" density group. It is mostly 
        intended for televisions and most apps shouldn't need it—providing mdpi and 
        hdpi resources is sufficient for most apps and the system will scale them as 
        appropriate. If you find it necessary to provide tvdpi resources,  
        you  should size them at a factor of 1.33*mdpi. 
        For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.

现在每个尺寸的最小分辨率定义如下

xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

也来自android Docs

dp 单位到屏幕像素的转换很简单:像素 = dps * (密度 / 160)。例如,在 240 dpi 屏幕上,1 dp 等于 1.5 个物理像素。强烈建议使用 dp 单位来定义应用程序的 UI,以确保在不同屏幕上正确显示 UI。

这意味着具有不同密度的两个不同设备可以具有相同数量的 dp 但不同的像素。

于 2013-10-29T04:32:29.910 回答
1

这个公式对我有用,可以获取屏幕尺寸并将它们转换为像素:

float scale = getBaseContext().getResources().getDisplayMetrics().density; 
int pixels = (int) (120 * scale + 0.5f);
于 2013-10-29T03:58:52.997 回答