1. 获取屏幕分辨率和像素密度
获取 Android 设备屏幕分辨率:
> adb shell wm size
Physical size: 1080x2400
获取android设备屏幕密度:
> adb shell wm density
Physical density: 420
打印屏幕相关的详细信息:
> adb shell dumpsys window displays
WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)
Display: mDisplayId=0 (organized)
init=1080x2400 420dpi mMinSizeOfResizeableTaskDp=220 cur=1080x2400 app=1080x2205 rng=1080x943-2268x2205
deferred=false mLayoutNeeded=false mTouchExcludeRegion=SkRegion((0,0,1080,2400))
2. 修改和重置屏幕分辨率和像素密度
修改屏幕分辨率
adb shell wm size 1080x2400
重置屏幕分辨率
adb shell wm size reset
设置屏幕像素密度(dpi)
adb shell wm density 480
重置屏幕像素密度(dpi)
adb shell wm density reset
3. 其他
修改屏幕分辨率和屏幕密度后,再次获取分辨率和密度时结果中会多出一个 “Override density” 字段,该字段时我们修改后的屏幕分辨率或屏幕密度。
重置屏幕分辨率或屏幕密度后它们就会恢复原有配置,再次查看时”Override density”就会消失
> adb shell wm size 540x960
> adb shell wm size
Physical size: 1080x2400
Override size: 540x960
> adb shell wm size reset
> adb shell wm size
Physical size: 1080x2400
> adb shell wm density 480
> adb shell wm density
Physical density: 420
Override density: 480
> adb shell wm density reset
> adb shell wm density
Physical density: 420