adb shell wm command analysis

wm(Window Manager)

The wm window management command can obtain information such as screen resolution and pixel density, and even temporarily modify parameters such as screen resolution and pixel density. Effect.

view help
wm

or

wm help

View screen resolution and pixel density
wm size # View the resolution of the screen, unit: px
wm density # View the pixel density of the screen, unit: dpi (dots per inch)

Modify the screen resolution and pixel density
wm size 720x1280 # Change the screen resolution (width x height) to: 720px * 1280px
wm size 360dpx640dp # Change the screen resolution (width x height) to: 360dp * 640dp
# The dp unit will be based on The current density is automatically converted to px

wm density 360 # Change the screen pixel density to 360 dpi

wm size reset # Undo the modification of the screen resolution (change back to the real physical resolution)
wm density reset # Undo the modification of the screen pixel density (change back to the real pixel density)

The three parameters of screen size, resolution, and pixel density are interrelated, and the third parameter can be calculated from two of them. The unit of pixel density is dpi (that is, the number of pixels per inch), so there is the following formula:

                像素点数(px)

Physical size (inch) = ---------------------
pixel density (px/inch)

Modifying the resolution and pixel density actually leads to a change in screen size after modification. Of course, this change is virtual, but it is modified to be consistent with the display effect (how much content is displayed) of the specified size screen:

The resolution is the same, the greater the pixel density (density), the smaller the screen size, the less content displayed (dp/sp as the display unit).
The same resolution, the smaller the pixel density (density), the larger the screen size, the more content displayed (dp/sp as the display unit).

Guess you like

Origin blog.csdn.net/weixin_44380181/article/details/129698198