【问题标题】:Large - Normal in Multiple Screens Android大 - 多屏幕 Android 中的正常
【发布时间】:2013-10-29 03:51:10
【问题描述】:

通过Supporting Different Densities,有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

【问题讨论】:

    标签: android screen multiscreen


    【解决方案1】:

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

    根据Android Developer's website

    尺寸

    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 文档

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

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

    【讨论】:

      【解决方案2】:

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

      float scale = getBaseContext().getResources().getDisplayMetrics().density; 
      int pixels = (int) (120 * scale + 0.5f);
      

      【讨论】:

      • 我想知道的只是:normal-xhpdi 是 720x1280,large-xhdpi 是 768x1280,等等...无论如何感谢您提供代码。
      • 只需将您的 dp 变量按比例放置并使用上面的公式...您将得到答案..i hv 提供了明确的答案。试一次,让我知道
      猜你喜欢
      • 1970-01-01
      • 2014-06-08
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      • 2013-01-22
      • 2014-10-24
      相关资源
      最近更新 更多