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...