http://developer.android.com/guide/practices/screens_support.html
测试屏幕分辨率的适配
How to Test Your Application on Multiple Screens
Figure 6. A set of AVDs for testing screens support.
Before publishing your application, you should thoroughly test it in all of the supported screen sizes and densities. The Android SDK includes emulator skins you can use, which replicate the sizes and densities of common screen configurations on which your application is likely to run. You can also modify the default size, density, and resolution of the emulator skins to replicate the characteristics of any specific screen. Using the emulator skins and additional custom configurations allows you to test any possible screen configuration, so you don't have to buy various devices just to test your application's screen support.
To set up an environment for testing your application's screen support, you should create a series of AVDs (Android Virtual Devices), using emulator skins and screen configurations that emulate the screen sizes and densities you want your application to support. To do so, you can use the AVD Manager to create the AVDs and launch them with a graphical interface.
To launch the Android SDK Manager, execute the
SDK Manager.exe
from your Android SDK directory (on Windows only) or execute
android
from the
<sdk>/tools/
directory (on all platforms). Figure 6 shows the AVD Manager with a selection of AVDs, for testing various screen configurations.
Table 3 shows the various emulator skins that are available in the Android SDK, which you can use to emulate some of the most common screen configurations.
For more information about creating and using AVDs to test your application, see Managing AVDs with AVD Manager.
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 | |
---|---|---|---|---|
Smallscreen | QVGA (240x320) | 480x640 | ||
Normalscreen | WQVGA400 (240x400) WQVGA432 (240x432) | HVGA (320x480) | WVGA800 (480x800) WVGA854 (480x854) 600x1024 | 640x960 |
Largescreen | WVGA800** (480x800) WVGA854** (480x854) | WVGA800* (480x800) WVGA854* (480x854) 600x1024 | ||
Extra Largescreen | 1024x600 | WXGA (1280x800)† 1024x768 1280x768 | 1536x1152 1920x1152 1920x1200 | 2048x1536 2560x1536 2560x1600 |
* To emulate this configuration, specify a custom density of 160 when creating an AVD that uses a WVGA800 or WVGA854 skin. ** To emulate this configuration, specify a custom density of 120 when creating an AVD that uses a WVGA800 or WVGA854 skin. † This skin is available with the Android 3.0 platform |
To see the relative numbers of active devices that support any given screen configuration, see the Screen Sizes and Densities dashboard.
Figure 7. Size and density options you can set, when starting an AVD from the AVD Manager.
We also recommend that you test your application in an emulator that is set up to run at a physical size that closely matches an actual device. This makes it a lot easier to compare the results at various sizes and densities. To do so you need to know the approximate density, in dpi, of your computer monitor (for instance, a 30" Dell monitor has a density of about 96 dpi). When you launch an AVD from the AVD Manager, you can specify the screen size for the emulator and your monitor dpi in the Launch Options, as shown in figure 7.
If you would like to test your application on a screen that uses a resolution or density not supported by the built-in skins, you can create an AVD that uses a custom resolution or density. When creating the AVD from the AVD Manager, specify the Resolution, instead of selecting a Built-in Skin.
If you are launching your AVD from the command line, you can specify the scale for the emulator with the
-scale
option. For example:
emulator -avd <avd_name> -scale 96dpi
To refine the size of the emulator, you can instead pass the
-scale
option a number between 0.1 and 3 that represents the desired scaling factor.
For more information about creating AVDs from the command line, see Managing AVDs from the Command Line