About Android nodpi, xhdpi, hdpi, mdpi, and ldpi

Source: Internet
Author: User

Original Source: http://618119.com/archives/2011/01/12/205.html

Author: lizongbo

Copyright Disclaimer: You can reprint the document at will. During reprinting, you must mark the original source and author information of the article in the form of a hyperlink and this copyright statement.


First, there are several basic concepts:

1. Screen Size
That is, the actual size of the display screen is measured based on the diagonal line of the screen.
For the sake of simplicity, Android divides all the screen sizes into four types: small, normal, large, and super large (corresponding to small, normal, large, and extra large ).
Applications can provide different custom screen la s for these four dimensions-the platform will select the corresponding layout for rendering based on the actual screen size, which is transparent to the program side.

2. screen aspect ratio Aspect Ratio
The aspect ratio is the ratio of the physical width to the physical height of the screen. Applications can use limited resources to provide screen layout resources for the specified aspect ratio.

3. Screen Resolution resolution
The total number of physical pixels displayed on the screen. Note that although the resolution is usually expressed in width x height, the resolution does not mean the specific aspect ratio of the screen.
In the andorid system, the application does not directly use the resolution.

4. Density
Specify the number of pixels that can be displayed within the physical width and height range based on the pixel resolution.
In the same wide and high area, the low-density display displays less pixels, while the high-density display displays more pixels.
Screen density is very important, because when other conditions remain unchanged, a total of wide and high Fixed UI components (such as a button) appear very large on the low-density display, on a high-density display screen, it looks small.
For simplicity, Android divides all screen resolutions into four sizes: small, common, large, and ultra-large (corresponding to small, normal, large, and extra large ).
Applications can provide different resources for these four dimensions-the platform transparently scales the resources to adapt to the specified screen resolution.

5. Device Independent pixel density-independent pixel (DP)
Applications can be used to define virtual pixel units of the UI component and describe the layout size and position in a density-independent manner.
A device independent pixel is equivalent to a physical pixel on a 160 DPI screen.
When the program is running, the system transparently processes independent pixel units of any devices that need to be scaled according to the actual density of the screen. The conversion of independent pixels of devices into actual pixels of the screen is very simple: pixels = DPS * (density/160 ).
For example, on a 240 DPI screen, an independent device pixel equals 1.5 physical pixels. to ensure that the UI components can be properly displayed on different screens, we strongly recommend that you use device independent pixel units to define your application UI.

Four types of screen sizes: small, normal, large, and xlarge
Four density classifications: ldpi (low), mdpi (medium), hdpi (high), and xhdpi (extra high)
It should be noted that xhdpi is added from Android 2.2 (API Level 8.
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.

Reference: http://developer.android.com/images/screens_support/screens-ranges.png

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

Drawable-nodpi-1280 x 720 (HD)


Values
Values-ldpi
Values-mdpi
Values-hdpi
Values-xhdpi
Values-nodpi
Values-nodpi-1024 × 600
Values-nodpi-1280 × 800
Values-nodpi-800 × 480

Reference: http://developer.android.com/guide/practices/screens_support.html

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.