Android-Summary of precautions for Screen Adaptation

Source: Internet
Author: User

1. Use LinearLayout and RelativeLayout whenever possible. Do not use absolute layout.
2. Try dip and sp instead of px.
3. provide different layout files and images for different resolutions.
For example:

4. Set multi-resolution support in AndroidMainfest. xml. Copy codeThe Code is as follows: <supports-screens
Android: largeScreens = "true"
Android: normalScreens = "true"
Android: anyDensity = "true"
Android: smallScreens = "true"/>


To sum up:
1) android: anyDensity = "true", the system will automatically find the corresponding folder Based on the screen density.
2) android: anyDensity = "false"
(1) If the drawable-hdpi, drawable-mdpi, and drawable-ldpi folders have different density representations of the same image resource, the system will load the resources in the drawable_mdpi folder.
(2) If drawable-hpdi contains high-density images and there is no corresponding image resource in the other two folders, the system will load resources in drawable-hdpi.
(3) If drawable-hdpi, drawable-mdpi has image resources, and drawable-ldpi does not have corresponding image resources, the system will load Resources in the drawable-mdpi folder.

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.