1. terms and concepts
Terms |
Description |
Remarks |
Screen Size) |
It refers to the actual physical size of the mobile phone, such as the commonly used 2.8 inch, 3.2 inch, 3.5 inch, 3.7 inch |
Motorola's milestone mobile phone is 3.7 inch |
Aspect Ratio (width/height ratio) |
Refers to the actual physical size width/height ratio, divided into long and nolong |
Milestone is and belongs to long |
Resolution (resolution) |
Similar to the definition of computer resolution, it refers to the number of pixels in the portrait and horizontal directions of the mobile phone screen. |
Milestone is 854*480 |
DPI (DOT per inch) |
Number of pixels per inch, such as 120 DPI and 320 DPI. Assume that the physical size of the qvga (240*2 inch) resolution screen is (1.5 inch * 160), DPI = |
Can reflect the definition of the screen, used to scale the UI |
Density (density) |
The pixel value concentration in the screen. Resolution/screen size can reflect the cell phone density, |
Density-independent pixel (DIP) |
The Unit for calculating the logic density. The formula for the dip and the specific pixel value is dip/pixel = DPI/160, that is, PX = DP * (DPI/160) |
2. DPI Value Calculation
For example, calculate the WVGA (800*480) Resolution, 3.7 inch density DPI, as shown in 1
Figure 1
Diagonal pixel indicates the pixel value of the diagonal line (=), DPI = 933/3. 7 = 252
3. Mobile phone screen Classification
3.1 is divided into the following three categories based on the cell phone screen density (DPI) or screen size, as shown in figure 2.
Figure 2
3. 2 The relationship between mobile phone screen classification and pixel density is shown in Table 1:
Lowdensity (120), ldpi |
Medium Density (1, 160), mdpi |
High density (240), hdpi |
Small Screen |
Qvga (240x320) |
Normal Screen |
Wqvga400 (240x400) wqvga432 (240x432) |
Hvga (320x480) |
Wvga800 (480x800) wvga854 (480X854) |
Large Screen |
Wvga800 * (480x800) wvga854 * (480X854) |
Table 1
3.3 mobile phone size distribution (http://developer.android.com/resources/dashboard/screens.html) 3 shows, the current is mainly to the resolution of 800*480 and 854*480 mobile phone users mostly
Figure 3
From the above screen size distribution, we can only consider mobile phones with a density of 1 and 1.5 between 3-inches.
4. uidesign
From the perspective of development, the application provides three sets of UI layout files based on the screen of three types of Android phones, but three sets of corresponding interface icons are also required, as shown in table 2.
Icon type |
Standard asset sizes (in pixels), for Generalized screen Densities |
Low Density screen (ldpi) |
Medium Density screen (mdpi) |
High density screen (hdpi) |
Launcher |
36x36 PX |
48x48 PX |
72X72 PX |
Menu |
36x36 PX |
48x48 PX |
72X72 PX |
Status Bar |
24x24 PX |
32x32 px |
48x48 PX |
Tab |
24x24 PX |
32x32 px |
48x48 PX |
Dialog |
24x24 PX |
32x32 px |
48x48 PX |
List View |
24x24 PX |
32x32 px |
48x48 PX |
Table 2
5. How can I achieve adaptive screen size?
1) interface Layout
Five layout Layout, similar to the title bar of the WINDOS window), layout-small (layout with a screen size less than 3 inch), layout-normal (screen size less than 4.5 inch ), layout-large (between 4 inch and 7 inch), layout-xlarge (between 7 and 10 inch)
2) image resources
You need to prepare 5 sets of image resources, including drawable, drawalbe-ldpi, drawable-mdpi, drawable-hdpi, and drawable-xhdpi Based on the DPI value.
Android has an automatic matching mechanism to select the corresponding layout and image resources.
Four types of screen sizes: small, normal, large, and xlarge
Four density classifications: ldpi (low), mdpi (medium), hdpi (high), and xhdpi (extra high)
Note that xhdpi is from
Android 2.2 (API Level 8) starts to increase the category.
Xlarge is a category added from Android 2.3 (API level 9.
DPI is the abbreviation of "dot Per Inch". The number of dots per inch.
Normal screen: ldpi is 120, mdpi is 160, hdpi is 240, and xhdpi is 320.
Two methods to obtain screen resolution information:
Displaymetrics metrics = new displaymetrics ();
Display display = activity. getwindowmanager (). getdefadisplay display ();
Display. getmetrics (metrics );
// The pixel value obtained here is the device independent pixel DP
// Displaymetrics metrics = activity. getresources (). getdisplaymetrics (); The obtained parameter information is incorrect. Do not use this method.
Android. content. res. Resources. getsystem (). getdisplaymetrics () cannot be used (). The obtained width and height are empty.
If you need to customize resource files for Android pad, the directory under the res directory may be:
Drawable
Drawable-ldpi
Drawable-mdpi
Drawable-hdpi
Drawable-xhdpi
Drawable-nodpi
Drawable-nodpi-1024 × 600
Drawable-nodpi-1280 × 800
Drawable-nodpi-800 × 480
Values
Values-ldpi
Values-mdpi
Values-hdpi
Values-xhdpi
Values-nodpi
Values-nodpi-1024 × 600
Values-nodpi-1280 × 800
Values-nodpi-800 × 480
Source code library» Android» res
Path: Android-4.0.1/packages/systemui/Res