Android adaptive resolution

Source: Internet
Author: User

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

 

Upper-level category

  • [Anim]
  • [Drawable]
  • [Drawable-hdpi]
  • [Drawable-large-hdpi]
  • [Drawable-large-mdpi]
  • [Drawable-large-xhdpi]
  • [Drawable-mdpi]
  • [Drawable-nodpi]
  • Drawable-sw600dp-hdpi
  • Drawable-sw600dp-mdpi
  • Drawable-sw600dp-xhdpi
  • [Drawable-xhdpi]
  • [Layout]
  • [Layout-land]
  • [Layout-port]
  • Layout-sw600dp
  • [Menu]
  • [Values]
  • [Values-AF]
  • [Values-Af-land]
  • [Values-Af-large]
  • [Values-am]
  • [Values-am-land]
  • [Values-am-large]
  • [Values-ar]
  • [Values-ar-land]
  • [Values-ar-large]
  • [Values-ar-port]
  • [Values-BG]
  • [Values-BG-land]
  • [Values-BG-large]
  • [Values-BG-port]
  • [Values-Ca]
  • [Values-ca-land]
  • [Values-ca-large]
  • [Values-ca-port]
  • [Values-Cs]
  • [Values-CS-land]
  • [Values-CS-large]
  • [Values-da]
  • [Values-da-land]
  • [Values-da-large]
  • [Values-de]
  • [Values-de-land]
  • [Values-de-large]
  • [Values-El]
  • [Values-el-land]
  • [Values-el-large]
  • [Values-en-RGB]
  • [Values-en-RGB-land]
  • [Values-en-RGB-large]
  • [Values-en-RGB-port]
  • [Values-es]
  • [Values-es-land]
  • [Values-es-large]
  • [Values-es-Rus]
  • [Values-es-Rus-land]
  • [Values-es-Rus-large]
  • [Values-fa]
  • [Values-fa-land]
  • [Values-fa-large]
  • [Values-fa-port]
  • [Values-fi]
  • [Values-fi-land]
  • [Values-fi-large]
  • [Values-fi-port]
  • [Values-fr]
  • [Values-fr-land]
  • [Values-fr-large]
  • [Values-hdpi]
  • [Values-Hi]
  • [Values-hi-land]
  • [Values-hi-large]
  • [Values-HR]
  • [Values-HR-land]
  • [Values-HR-large]
  • [Values-HR-port]
  • [Values-hu]
  • [Values-hu-land]
  • [Values-hu-large]
  • [Values-hu-port]
  • [Values-in]
  • [Values-in-land]
  • [Values-in-large]
  • [Values-in-port]
  • [Values-It]
  • [Values-it-land]
  • [Values-it-large]
  • [Values-IW]
  • [Values-IW-land]
  • [Values-IW-large]
  • [Values-IW-port]
  • [Values-Ja]
  • [Values-ja-land]
  • [Values-ja-large]
  • [Values-ko]
  • [Values-ko-land]
  • [Values-ko-large]
  • [Values-land]
  • [Values-large]
  • [Values-large-port]
  • [Values-lt]
  • [Values-lt-land]
  • [Values-lt-large]
  • [Values-lt-port]
  • [Values-LV]
  • [Values-LV-land]
  • [Values-LV-large]
  • [Values-LV-port]
  • [Values-ms]
  • [Values-MS-land]
  • [Values-MS-large]
  • [Values-Nb]
  • [Values-Nb-land]
  • [Values-Nb-large]
  • [Values-nl]
  • [Values-NL-land]
  • [Values-NL-large]
  • [Values-pl]
  • [Values-pl-land]
  • [Values-pl-large]
  • [Values-port]
  • [Values-pt]
  • [Values-Pt-land]
  • [Values-Pt-large]
  • [Values-Pt-RPT]
  • [Values-Pt-RPT-land]
  • [Values-Pt-RPT-large]
  • [Values-RM]
  • [Values-ro]
  • [Values-ro-land]
  • [Values-ro-large]
  • [Values-ro-port]
  • [Values-Ru]
  • [Values-Ru-land]
  • [Values-Ru-large]
  • [Values-SK]
  • [Values-SK-land]
  • [Values-SK-large]
  • [Values-SK-port]
  • [Values-Sl]
  • [Values-Sl-land]
  • [Values-Sl-large]
  • [Values-Sl-port]
  • [Values-Sr]
  • [Values-Sr-land]
  • [Values-Sr-large]
  • [Values-Sr-port]
  • [Values-SV]
  • [Values-SV-land]
  • [Values-SV-large]
  • [Values-SW]
  • [Values-SW-land]
  • [Values-SW-large]
  • Values-sw600dp
  • Values-sw600dp-port
  • Values-sw720dp
  • Values-sw720dp-port
  • [Values-th]
  • [Values-th-land]
  • [Values-th-large]
  • [Values-th-port]
  • [Values-Tl]
  • [Values-Tl-land]
  • [Values-Tl-large]
  • [Values-Tl-port]
  • [Values-tr]
  • [Values-tr-land]
  • [Values-tr-large]
  • [Values-uk]
  • [Values-UK-land]
  • [Values-UK-large]
  • [Values-UK-port]
  • [Values-VI]
  • [Values-vi-land]
  • [Values-vi-large]
  • [Values-vi-port]
  • [Values-xhdpi]
  • [Values-ZH-RCN]
  • [Values-ZH-RCN-land]
  • [Values-ZH-RCN-large]
  • [Values-ZH-RTW]
  • [Values-ZH-RTW-land]
  • [Values-ZH-RTW-large]
  • [Values-zu]
  • [Values-zu-land]
  • [Values-zu-large]

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.