Android各种屏幕的分布率以及自适应各种屏幕的开发研究
下图表明了现在持有Android设备的屏幕分辨率的大概的一个分布,从中可看到mdpi跟hdpi的nomal分类占据了84%!所以我们的程序最开始要尽量适应这俩种设备。
![](https://img.paonet.com/upload-images-old/img/ ldpi_chd_t_7.4_0.3_2.0_57.8_0.7_26.2_0.9_2.4_2.3.png)Data collected during a 7-day period ending on May 1, 2012
| ldpi | mdpi | hdpi | xhdpi |
---|---|---|---|---|
small | 2.3% | | 2.4% | |
normal | 0.7% | 26.2% | 57.8% | 0.9% |
large | 0.3% | 2% | | |
xlarge | | 7.4% | | |
那么下图则给出了各种分辨率屏幕的对应关系,标注红色的部分就是我们需要关心的。他们分别位于mdpi跟hdpi。
**Table 3.**Various screen configurations available from emulator skins in the Android SDK (indicated in bold) and other representative resolutions.
| Low density (120), ldpi | Medium density (160), mdpi | High density (240), hdpi | Extra high density (320), xhdpi |
---|---|---|---|---|
_Small_screen | QVGA (240x320) | | 480x640 | |
_Normal_screen | **WQVGA400 (240x400) | |||
WQVGA432 (240x432)** | HVGA (320x480) | **WVGA800 (480x800) | ||
WVGA854 (480x854)** | ||||
600x1024 | 640x960 | |||
_Large_screen | WVGA800 (480x800) | |||
WVGA854** (480x854)** | *WVGA800 (480x800) | |||
WVGA854* (480x854)** | ||||
600x1024 | | | ||
_Extra Large_screen | 1024x600 | WXGA (1280x800)† | ||
1024x768 | ||||
1280x768 | 1536x1152 | |||
1920x1152 | ||||
1920x1200 | 2048x1536 | |||
2560x1536 | ||||
2560x1600 |
-
_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
那么如何针对mdpi跟hdpi做开发呢?我们通常在编写布局文件的时候碰到ps,dp等单位,建议大家使用dp来自适应各种屏幕,下面是dp对应屏幕分辨率:
-
320dp: a typical phone screen (240x320 ldpi,320x480 mdpi,480x800 hdpi, etc).
-
480dp: a tweener tablet like the Streak (480x800 mdpi).
-
600dp: a 7” tablet (600x1024 mdpi).
-
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
其中计算公式是:px = dp * (dpi / 160)
参考:http://developer.android.com/resources/dashboard/screens.html
http://developer.android.com/guide/practices/screens_support.html