android 螢幕 解析度

心鑫發表於2013-11-09
Fields
public float density

Added in API level 1
The logical density of the display. This is a scaling factor for the Density Independent Pixel unit, where one DIP is one pixel on an approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen), providing the baseline of the system's display. Thus on a 160dpi screen this density value will be 1; on a 120 dpi screen it would be .75; etc.

This value does not exactly follow the real screen size (as given by xdpi and ydpi, but rather is used to scale the size of the overall UI in steps based on gross changes in the display dpi. For example, a 240x320 screen will have a density of 1 even if its width is 1.8", 1.3", etc. However, if the screen resolution is increased to 320x480 but the screen size remained 1.5"x2" then the density would be increased (probably to 1.5).

See Also
DENSITY_DEFAULT


1.標準是240*320畫在1.5*2平方inch上。那麼像每平方英寸有240*320/(1.5*2)=25600點,也就是一平方英尺的畫素點為 25600,所以dpi取為它的平方根160;如果你的dpi是120,那麼它的密度就是0.75
2. 它要說明的是密度不只是與width有關,還與height有關,所以舉例說,不管width是1.8還是1.3,它的密度都有可能是1;比如width 是1.8,只要它的height是3/1.8的話,如果pixel為240*320的話,它的密度仍舊是1;同樣如果width為1.3,只要它的 height為3/1.3的話,畫素點為240*320,則密度也是1.
3. 320*480/(1.5*2)得到單位平方英寸的點為51200,所以單位平方英寸是240*320畫在1.5*2螢幕的2倍。但是這是平方英寸啊,算密度的時候要開平方的啊,所以應該是2開平方,是1.414吧,大致密度為1.5

相關文章