Problem:
During the test, it is found that the Display Effect of applications on different monitors is different (some texts cannot be completely displayed). Naturally, the screen adaptation problem occurs.
Sort the rules as follows:
(1) several concepts
1. Screen size: the size of the Screen, that is, the diagonal line length (unit: inch-inch)
2. Screen density: Screen density, that is, number of pixels per unit length (pots/inches)
3. Resolution, that is, the total number of pixels on the screen (width * height)
4. Density-independent pixel (dp) independent pixel Density. The standard is 160dip. That is, 1dp corresponds to 1 pixel. The calculation formula is px = dp * (dpi/160). The larger the screen density, the more pixels corresponding to 1dp.
(2) screen classification (size & density)
1. Change the number of pixels and the size of the text, as shown in
Each category has its minimum resolution, as shown in the following figure. You can divide the categories based on the resolution:
2. provide different images by screen density, as shown in
Note1: match the above two types for reference.
Note2: there are also two types of products designed for horizontal (landscape) and vertical (portrait), which are rarely used and will not be described here.
(3) how Android looks for optimal resources
1. exclude resources that do not match the device settings
2. Search by qualifier in order
3. Whether the resource path exists under the qualifier
4. Exclude the resource paths that are not included in the qualifier
5. continue to search for different qualified words until corresponding resources are found.
As shown in:
(4) project steps:
1. configuration in manufest
<supports-screens
Android: anyDensity = "true"
Android: largeScreens = "true"
Android: normalScreens = "true"
Android: smallScreens = "true"
Android: xlargeScreens = "true"/>
2. Create a new resource folder.
A, Layout
As shown in:
B, Drawable
As shown in:
In drawable, the standard is mdpi (160 dpi ). The ratio is 3: 4: 5: 6, as shown in: