Android 屏幕適配

原文


The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen. At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi screen, 1 dp equals 1.5 physical pixels. You should always use dp units when defining your application's UI, to ensure proper display of your UI on screens with different densities.


從上文可以看出  px=dp*(dpi/160);

其中

px指的是屏幕實際分辨率,如小米2s的分辨率爲720px * 1280px

dpi=160*density,如小米2s的分辨率爲320

其中小米2s爲360dp


手機:大部分手機的dp均爲320,但這也由density來決定

type    value  

ldpi      120dpi

mdpi    160dpi

hdpi     240dpi

xdpi     320dpi

tvdpi    213dpi


pad:大部分pad的dp均在600以上

sw600dp                   

(10'')800x1280        213dpi       dp=601(sw600dp或sw600dp-mdpi中的資源寬爲600,佔滿屏幕的3/4,sw600dp-xdpi中的資源寬爲600,只佔3/8)

(7'')  600x1024        160dpi       dp=600(sw600dp或sw600dp-mdpi中的資源寬爲600,佔滿屏幕寬,sw600dp-xdpi中的資源寬爲600,只佔一半)




240x320   ldpi

320x480  mdpi

480x800 hdpi

720x1280 xhdpi


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章