Android Multi-resolution self-adaptation summary

Source: Internet
Author: User

This week's work adjusts to the multi-resolution adaptive adaptation of Android projects. Therefore, the knowledge in this area is constantly trying to learn. The Android project must develop a programming habit when it first starts, and all resource calls are placed in value. Unified naming and management. summarizes the following content.

I. GENERAL basic principles and summary
1, the XML layout do not write dead, not only units do not use PX, as far as possible with DP, or match, warp
2, should try to make the resource picture can be stretched. 9 figure, if there is a gradient, as far as possible in the direction of horizontal or vertical gradient, this can greatly reduce the size of the installation package, but also to improve processing speed.
3, if you do not want to design multiple sets of pictures, then design the largest set. Compression is always better than stretching, put in drawable-xhdpi this folder.
4, write several sets of value values, corresponding to different resolutions. A set of layout can be. As shown in.



5, set up multiple layout folders, folder name is layout-800x480 and so on. What you need to adapt to that resolution. (This way is too tired, it will also lead to large applications, not recommended)

6, forced to rewrite some of the layout of XML.
layout-1024x768
layout-1024x600
layout-1280x768
layout-land-1024x720//1024x768 Horizontal Screen
layout-port-976x768//1024x768 Vertical Screen
Note the format, "layout"-"Port/land"-"Length x width"
Precautions:
After android3.0, to fit the resolution above, the height minus 48 pixels, i.e. the height of the bottom status bar, is recognized by Android.
A large number in the resolution must be written to the front, otherwise a syntax error is generated.

7.

<supports-screensandroid:largescreens= "true" android:normalscreens= "true" android:anydensity = "true"/>
android:anydensity= "True", this sentence is very important to the entire screen, the value is true, our application when installed on a different density of mobile phones, the program will load the resources in the HDPI,MDPI,LDPI folder separately.

Add the above code between the </application> tab and the </manifest> tag. Can be

Second, attach the Android part screen resolution, pixel knowledge.
Low Density (ldpi),
medium Density (mdpi),
High Density (hdpi),
small Screen
1, QVGA (240x320), 2.6~3.0 inch
Normal Screen
1, WQVGA (240x400), 3.2~3.5 inch
2, FWQVGA (240x432), 3.5~3.8 inch
3, HVGA (320x480), 3.0~3.5 inch
4, WVGA (480x800), 3.3~4.0 inch
5, FWVGA (480x854), 3.5~4.0 inch
Big screen
1, WVGA (480x800), 4.8~5.5 inch
2, FWVGA (480x854), 5.0~5.8 inch

Screen size is divided into: small,normal,large,xlarge, respectively, small, medium, large, large screen
Screen density is divided into: ldpi,mdpi,hdpi,xhdpi, their standard values are: 120dpi,160dpi,240dpi,320dpi

PX (pixels): The point on the screen.
In (inches): unit of length.
MM (mm): unit of length.
PT (lb): 1/72 inches.
DP (density-independent pixels): An abstract unit based on screen density. 1DP = 1px on a monitor 160 dots per inch.
Dip: Same as DP, more for android/ophone example.
SP (scale independent pixels): Similar to DP, but can be scaled based on the user's font size preference.

Thus, according to Google's suggestion, TextView's font size is best to use SP to do units, and view the source of TextView know that Android by default using the SP as the font size units.

The recommendations on SP and DP selection are:
1, if the TextView display area can be elastic change (wrap_content, of course, all of its parent view also needs to be elastic change), then the SP can be given priority, when the font size changes generally will not disrupt the usability of the interface

2, in contrast with 1, the display area of the TextView has been limited to a fixed value (or its parent view is limited), it is preferred to use DP bar, or encountered the user who has been using the super-large font, the font may be truncated, and users do not know, will feel is a procedural problem.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Multi-resolution self-adaptation summary

Related Article

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.