Android screen adaptation

Source: Internet
Author: User

1. The best way to adapt the screen to multiple resolutions may be to use the weight attribute.

You can use the Layout_weight property in a linetype layout to make the control appear proportionally. This will result in a consistent display at different screen resolutions.

There are two ways to use this property:

1. Set the value of Layout_width or layout_height (depending on whether you want to display proportionally on length or width) to match_parent.

In this case, the smaller the weight value, the larger the area. The disadvantage of this method is that the proportions need to be computed by themselves, because it is reversed.

2. Set the value of Layout_width or layout_height (depending on whether you want to proportionally display the length or width) to 0 px.

In this case, the larger the weight value, the greater the area.

However, the weight property is not valid for relative layout. So you need to be careful when you use it.

************************************************************************************

2. You can also use code to get the screen resolution layout. The advantage is accuracy, disadvantage is trouble. Because the size of all the controls needs to be reset in the code, it's very cumbersome. This method is not suitable for many layout situations in the project.

3. You can also design a separate layout for each resolution. Disadvantage or trouble, because there are so many resolutions. The pros are still accurate.

An article is available for reference:

Http://www.eoeandroid.com/thread-173973-1-1.html

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.