Android使用adb wm命令调整手机分辨率

Androidadb评论 1大约 1928 字

wm命令修改屏幕的参数

wm:WindowManager

adb shell wm
或进入shell模式后直接输入wm

输出:

usage: wm [subcommand] [options]
       wm size [reset|WxH|WdpxHdp]
       wm density [reset|DENSITY]
       wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]
       wm scaling [off|auto]
       wm screen-capture [userId] [true|false]

wm size: return or override display size.
         width and height in pixels unless suffixed with 'dp'.

wm density: override display density.

wm overscan: set overscan area for display.

wm scaling: set display scaling mode.

wm screen-capture: enable/disable screen capture.

wm dismiss-keyguard: dismiss the keyguard, prompting the user for auth if necessary.

如报错:

java.lang.SecurityException: Must hold permission android.permission.WRITE_SECURE_SETTINGS
        at android.os.Parcel.readException(Parcel.java:1599)
        at android.os.Parcel.readException(Parcel.java:1552)
        at android.view.IWindowManager$Stub$Proxy.setForcedDisplaySize(IWindowManager.java:1308)
        at com.android.commands.wm.Wm.runDisplaySize(Wm.java:164)
        at com.android.commands.wm.Wm.onRun(Wm.java:87)
        at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
        at com.android.commands.wm.Wm.main(Wm.java:46)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:357)

在开发者选项中打开USB调试(安全设置)

wm size

查询和修改当前设备的尺寸,使用x(xyz的x)进行连接。

查询设备尺寸

wm size

输出:

Physical size: 1080x1920

修改设备尺寸

wm size 720x1280

修改后设备尺寸:

Physical size: 1080x1920
Override size: 720x1280

还原设备尺寸

wm size reset

wm density

查看和修改当前设备的density参数。

查询设备density

wm density

输出:

Physical density: 480

修改设备density

wm density 420

修改后设备density:

Physical density: 480
Override density: 420

还原设备density

wm density reset

wm overscan

修改当前设备的屏幕内边距,左上右下顺序

修改屏幕内边距

wm overscan 20,20,20,20

还原屏幕内边距

wm overscan reset

常用的设备参数

  • 480,1080x1920
  • 460,1080x1920
  • 320,720x1280
  • 560,1440x2392
阅读 5152 · 发布于 2019-04-09

————        END        ————

扫描下方二维码关注公众号和小程序↓↓↓

昵称:
  • cooldish1楼
    冰冰是醉吼滴
    Chrome 74.0 | Win102020.03.03
    作者回复
    访访最棒!
    Chrome 79.0 | Win102020.03.08
随便看看换一批