Android devices run on a variety of screens that have different screen sizes (screen sizes) and screen densities (display density). Screen sizes represents the actual physical size of the screens, such as 5-inch mobile phones, 7-inch tablets, and 8-inch tablets. Screen densities, for example, has a 720p of 1080p of pixel density, like the same 5-inch cell phone. Screens sizes and screen densities represent the properties of the display from two dimensions, and they do not affect each other.
Screen Sizes
The actual physical size of the screen, measured diagonally on the screen, generally in inch (inch) units, such as 5-inch mobile phone, 7-inch tablet. As shown in the following:
Depending on the screen size, you can divide the screen size into the following types:
< yo? " http://www.2cto.com/kf/ware/vc/"target=" _blank "class=" Keylink "> Vcd4kcnntywxsbm9ybwfsbgfyz2v4bgfyz2ukpgltzybzcmm9 "http://www.2cto.com/uploadfile/Collfiles/20140522/ 2014052209133874.jpg "alt=" \ ">
This classification is based on the first Android phone G1, G1 belongs to the normal category. As the size of the Android phone screen becomes more and more plentiful, this classification is simply rude, unable to meet the accuracy of the classification (such as 5-inch mobile phones and 7-inch tablets belonging to the large category). So after android3.2, this classification is not used, the new classification method is defined by the available screen width, in the project resource file (such as layout) use, here are some examples: LAYOUT-SW600DPLAYOUT-SW720DP
VALUES-SW340DP the definition of these classifications will be explained in detail later, now we have a concept.
Screen densities
There are several concepts to understand before you speak screen densities: px,ppi,dpi,resolution.
1. px
PX is often said pixels (pixel), pixels are the basic unit of image display, pixel by the picture and element two words, with the meaning of the image element, each such information element is an abstract sampling, often expressed as a point or a square.
2. PPI
The PPI (pixels per inch) represents the number of pixels per inch in the image, and the PPI affects the quality of the screen output, and the high PPI has more pixel counts per inch, which shows better results. For a 100-pixel picture, the output of 100ppi shows a size of 1 "x 1" (1 "for 1"), and the output in 10ppi shows a size of "x 10". That is, the same picture in the different PPI display size is not the same, the larger the PPI, the smaller the picture appears.
3. DPI
DPI (dots per inch) and PPI are two more confusing concepts, DPI represents the number of physical display points per inch of the screen, the physical display point is the smallest display unit of the screen. The false output corresponds to the display point one by one of the screen, i.e. a pixel is displayed on a dot, then the DPI value equals the PPI. But if you output a 300ppi image in full screen with a 1200dpi screen, then each pixel is made up of 16 dots. (DPI vs. ppi)
4. Resolution
Resolution represents the screen resolution, expressed in pixels, such as the screen resolution of x 1080, which indicates that the screen x, y direction can display 1920 and 1080 pixels respectively. The resolution does not play a direct role when the application realizes multi-screen adaptation, and the multi-screen adaptation is only relevant to screens sizes and densities.
After a preliminary understanding of the above concepts, let's look at the classification of screen densities, in Android, screen densities is sorted by DPI, as follows: ldpi (Low) ~120dpimdpi (medium) ~160DPIHDPI (High) ~240dpixhdpi (Extra high) ~320dpixxhdpi (extra Extra high) ~480dpixxxhdpi (extra extra extra high) ~ 640dpi ...
For simplicity, Android classifies screen densities according to DPI values, each of which contains a region's DPI value, as shown in. This classification is also based on the first Android phone G1 as a benchmark, G1 dpi of 160dpi, belongs to the MDPI classification.
Below the PPI formula, PPI is pixels per inch, the PPI of the device is represented by the number of pixel per inch in the diagonal of the screen,
For example NEXUS5 mobile phone, the resolution is 1080, the screen size is 4.95 inches, then the PPI calculation is as follows:
The DPI of the screen how to calculate, if it is by definition, the formula is the same as the PPI formula, just the number of pixels into dot, but we do not know the number of dot. However, we can get the DPI value of the device through the program, the code is as follows:
?
12 |
DisplayMetrics dm = getResources().getDisplayMetrics(); int dpi = dm.densityDpi; |
dpi=480 obtained by the above code, that is, DPI is not equal to the PPI, if a pixel with a dot display, according to the truth should be equal, but why not wait? I haven't figured that out yet. Anyway, to get the dpi of the screen, you can't use the formula to calculate the PPI to get it, to get it from the code.
Summarize:
The differences in screen of Android devices are divided by two dimensions, screens sizes and densities, and for simplicity, Android classifies the different screenshots sizes and the onscreen densities. They do not affect each other, one represents the actual physical size of the screen, a pixel density representing the screen, and the different combinations of the two make up a variety of device screens. They are a major consideration when it comes to multi-screen adaptation of Android applications.
Android screen classification and screen-related parameter definition (RPM)