Research on Android pixel conversion (2)

Source: Internet
Author: User

How to make the Virtual Machine display the same as the real machine

Original article, if reproduced, please indicate the source: http://blog.csdn.net/yihui823/article/details/6734547

Previously we came to the conclusion that:

For the same dip, the relative width of the screen is the same on the screen with different resolutions. The relative width can be understood as the percentage of a widget's screen.

When density = 160, 1dip = 1px

We can get this formula:

Desity: 160 = px: dip

Now we will continue our research. Let's change the comparison method.

Comparison 2:

This time, we compare a screen with a different aspect ratio and a screen with the same width.

Virtual Machine 1:

PIX-003

The result is as follows:

PIX-004

 

Virtual Machine 3:

PIX-007

Display Effect:

PIX-008

 

 

Wow! It's totally different. It's all changed.

The same density, the same 240 DPI, but one button occupies all width, and the other button only occupies about 3/4 width. This is totally different from the previous conclusion.

The explanation can only be: different screen aspect ratios, even with the same density, are useless.

But let's take a closer look, as if the height ratio is the same.

Let's take a look at the situation at the same height:

 

Comparison 3:

Virtual Machine:

PIX-003

The result is as follows:

PIX-004

 

Virtual Machine 4:

PIX-009

The effect is as follows:

PIX-010

As you can see, it is displayed according to the ratio of height.

 

So we can conclude that if we press dip to control the button size and position:

1. When the ratio of the screen length to width is different, the ratio is converted to height.

2. the aspect ratio of the widget does not change with the aspect ratio of the screen.

3. After the aspect ratio of the screen is changed, the control coordinates the relative position and size of the control in proportion to the height.

 

When the ratio of the screen length to width is different, the formula is as follows:

Desity: 160 = px: dip

Is calculated by height, and the width is invalid.

To be continued...

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.