1. 连接上设备,在控制台输入命令 adb shell wm help
home@home-MS-7B89:~$ adb shell wm helpWindow manager (window) commands:helpPrint this help text.s XXX 1 //or 0, true, falseSet WindowManagerDebugConfig debug param to true/false.s debug_savestate 1 //or 0, true, falseSet save WindowManagerDebugConfig debug state.s debug_liststate 1 //or 0, true, falseList WindowManagerDebugConfig debug state.p XXX 1 //or 0, true, falseSet PhoneWindowManager debug param to true/false.p debug_savestate 1 //or 0, true, falseSet save PhoneWindowManager debug state.p debug_liststate 1 //or 0, true, falseList PhoneWindowManager debug state.c windowName /data/misc/wmtrace/a.pngcapture the specific window's layer to bimmapsize [reset|WxH|WdpxHdp]Return or override display size.width and height in pixels unless suffixed with 'dp'.density [reset|DENSITY]Return or override display density.overscan [reset|LEFT,TOP,RIGHT,BOTTOM]Set overscan area for display.scaling [off|auto]Set display scaling mode.dismiss-keyguardDismiss the keyguard, prompting user for auth ifnecessary.folded-area [reset|LEFT,TOP,RIGHT,BOTTOM]Return or override folded area.set-user-rotation [free|lock] [-d DISPLAY_ID] [rotation]Set user rotation mode and user rotation.set-fix-to-user-rotation [-d DISPLAY_ID] [enabled|disabled]Enable or disable rotating display for app requested orientation.tracing (start | stop)Start or stop window tracing.
2. 上图是wm全部的命令, 我挑选工作中平时用的做解释说明
1)adb shell wm size
说明:查看屏幕的分辨率, 返回屏幕的宽高像素, 单位: px
adb shell wm sizePhysical size: 1200x1920
2) adb shell wm size 1080x1920
说明: 自定义设置屏幕的分辨率 宽为1080px 高为1920px
adb shell wm size 1080x1920Physical size: 1200x1920Override size: 1080x1920
3) adb shell wm size reset
说明:把自定义的屏幕分辨率设置参数 重置
4) adb shell wm density
说明: 查看设备屏幕密度
adb shell wm densityPhysical density: 320
5) adb shell wm density 240
说明: 自定义设置设备屏幕密度
adb shell wm density 240Physical density: 320Override density: 240
同样 adb shell wm density reset 命令: 重置参数恢复默认
6)adb shell wm overscan
说明: 设置显示区域大小 , 坐标值:依次为左、上、右、下
adb shell wm overscan 100,200,300,400
同样 adb shell wm overscan reset : 重置参数恢复默认
7)adb shell wmdismiss-keyguard
说明: 前提没有设置数字,图案,PIN密码,如果是锁屏待机状态,执行此命令后,直接解锁进入桌面
8)adb shell wm c xxx
说明:将特定窗口的图层捕获为bimmap,然后存到设备 /data/misc/wmtrace/a.png 此路径下
adb shell wm c dsfuse the default file path name /data/misc/wmtrace/a.pngWindowName = dsfcan not find the window dsf