最受欢迎的dpi值

时间:2012-10-10 09:47:37

标签: android android-view

我在哪里或哪里可以找到最受欢迎的设备dpi规格?我有一个布局,其中ImageView的参数化为dp值,为了提供最适合任何设备的服务器,给定特定的像素参数可以生成必要的图像。

因此,对于px = dp * (dpi / 160),我需要定义最流行的dpi变体来计算服务器的像素数据。

感谢。

2 个答案:

答案 0 :(得分:1)

您实际上可以使用所需的确切大小查询服务器。

float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, intContainingYourDPs, getResources().getDisplayMetrics());

答案 1 :(得分:0)

//这些是Google API支持的唯一密度。

设备制造商可以为设备提供自己的密度

假设galaxy 3是306 dpi但是android会将其视为306/160=1.9

所以DENSITY_XHIGH它将从xhdpi获取资源。

public static final int DENSITY_DEFAULT
Since: API Level 4
The reference density used throughout the system.
Constant Value: 160 (0x000000a0)

public static final int DENSITY_HIGH
Since: API Level 4
Standard quantized DPI for high-density screens.
Constant Value: 240 (0x000000f0)

public static final int DENSITY_LOW
Since: API Level 4
Standard quantized DPI for low-density screens.
Constant Value: 120 (0x00000078)

public static final int DENSITY_MEDIUM
Since: API Level 4
Standard quantized DPI for medium-density screens.
Constant Value: 160 (0x000000a0)

public static final int DENSITY_TV
Since: API Level 13
This is a secondary density, added for some common screen configurations. It is recommended that applications not generally target this as a first class density -- that is, don't supply specific graphics for this density, instead allow the platform to scale from other densities (typically DENSITY_HIGH) as appropriate. In most cases (such as using bitmaps in Drawable) the platform can perform this scaling at load time, so the only cost is some slight startup runtime overhead.

This density was original introduced to correspond with a 720p TV screen: the density for 1080p televisions is DENSITY_XHIGH, and the value here provides the same UI size for a TV running at 720p. It has also found use in 7" tablets, when these devices have 1280x720 displays.    
Constant Value: 213 (0x000000d5)

public static final int DENSITY_XHIGH
Since: API Level 9
Standard quantized DPI for extra-high-density screens.
Constant Value: 320 (0x00000140)

public static final int DENSITY_XXHIGH
Since: API Level 16
Standard quantized DPI for extra-extra-high-density screens. Applications should not generally worry about this density; relying on XHIGH graphics being scaled up to it should be sufficient for almost all cases.
Constant Value: 480 (0x000001e0)
相关问题