1, Android Phone common resolution
wvga:800x480
fwvga:854x480
qhd:960x540
720p:1280x720 (SD, Standard DEFINITION,SD)
1080p:1920x1080 (HD, High DEFINITION,HD)
2, the resolution corresponds to DPI
DPI (dots per inch, point in dots)
hdpi corresponds to WVGA, FWVGA, QHD.
xhdpi corresponds to 720P.
xxhdpi corresponds to 1080P.
3. Androidmanifest.xml setting
Android:anydensity= "true" when the application is installed on a different density terminal, the program loads the resources in the xxhdpi, xhdpi, hdpi, MDPI, ldpi folders, respectively.
When android:anydensity= "false", the app does not automatically look for resources under the folder even if it has the same resources under the folder.
4, Horizontal screen vertical screen directory to distinguish
1) drawable
DRAWABLE-LAND-HDPI, the resource for this folder is loaded when the screen is horizontal and high density.
DRAWABLE-PORT-HDPI, when the screen is vertical and high density, the resources in this folder are loaded.
(2) Layout
In the Res directory, the establishment of the Layout-port and Layout-land two directories, respectively, a vertical screen and two horizontal screen layout files, to adapt to the horizontal screen vertical screen automatically switch.
5. Multi-screen adaptation principle
(1) fill_parent, Match_parent, Wrap_content, and DP should be used when setting the control dimensions in the layout file. Specifically, Fill_parent, Match_parent, Wrap_content, and DP are better than PX when setting the values of the view's properties Android:layout_width and Android:layout_height. The text size should be defined using the SP.
(2) Do not appear in the code of the program specific pixel values, defined in the Dimens.xml. To accommodate multiple screens, Android recommends that developers not use specific pixels to represent the size of the control.
6.9-patch Pictures
In Android, you can use not only normal images of. png,. jpg,. gif as a picture resource, but also 9-patch images with the extension. 9.png as a picture resource. The Draw9patch tool under the Android SDK directory tools can generate a scalable standard PNG image with the extension. 9.png. 9-patch pictures are often used as backgrounds, and unlike normal images, when you use a 9-patch image as a screen or a button background, when the screen size or button size changes, the picture is automatically scaled to achieve an undistorted effect.
9-patch a PNG image, empty a pixel interval around the native PNG image to identify which parts of the PNG picture can be stretched, which cannot be stretched, the border position on the background, and so on.
7. Different layout
How can application automatically adapt to different screens?
In fact, it is very simple to create a different layout folder in the Res directory, such as layout-640x360, layout-800x480, etc. All layout files are written to R.java after compilation, and the system uses the appropriate layout according to the size of the screen.
8, dip, DP, PX, SP introduction
Dip:device independent pixels, device independent pixels.
DP: Very simple, and the dip is the same.
Px:pixel, pixels.
sp:scaled pixels, mainly used for font display.
9. Screen resolution, size, density
(1) Screen resolution: screen resolution is the number of pixels on the screen of the mobile phone, which is how many pixels of the screen, generally described as the "width x height" of the screen. The common resolutions of the Android phone screen are 480x800, 720x1280, 1080x1920, etc., such as 720x1280 that the screen has 720 pixels in the width direction and 1280 pixels in the height direction.
(2) Screen size: The screen size is the physical size of the diagonal of the phone, in inches (inch) units. For example, a mobile phone for "5-inch large-screen mobile phone" refers to the diagonal size of 5 inches, 5 inches x2.54 cm/inch = 12.7 centimeters.
(3) Screen density: The screen density is the pixel points per inch, the higher the value of course the more delicate display. For the screen, the larger the DPI, the higher the fineness of the screen, the more clearly the screen will look. The phone can have the same resolution, but the screen size can be different.