Control android screen display with WM
Being able to emulate other devices screen size, density and control the area of the display with a singular command is a great advantage for both developers and testers. Luckily Android provides us with a useful tool, purely for that purpose.
WM (Window manager) (no root required) easily allows for changing various properties of the screen.
$ adb shell wm [subcommand] [options]
- size -> for changing the size (resolution) of the screen
- density -> changing screen dpi
- overscan -> creating screen margin
Changing screen resolution is the quickest way of verifying how particular app/action/behavior would look on screen with different resolution.
adb shell wm size -> display Physical and Override (when changed) size of the screen
Physical size -> actual resolution of the size of the screen
Override size -> wm emulated screen size
adb shell wm size WxH W -> override screen with this width H -> override screen with this height
adb shell wm size reset -> reset screen size to original (physical) value
Changing how dense pixels emulation is on a display.
adb shell wm density -> display Physical and Override density of the screen
adb shell wm density X X -> override screen density with this value
adb shell wm density reset -> reset screen density to original (physical) value
Allows adding margins to display for greater control over the screen – useful when trying to emulate small screen (phone) on a tablet.
adb shell wm overscan a,b,c,d a -> left edge margin b -> top edge margin c -> right edge margin d -> bottom edge margin
adb shell wm size reset -> reset overscan to original values