獲取當(dāng)前方向一:
adb shell "dumpsys input | grep SurfaceOrientation"
# 縱向(正常狀態(tài):順時(shí)針旋轉(zhuǎn)0°):SureaceOrientation 的值為 0
# 橫向(順時(shí)針旋轉(zhuǎn)90°): SureaceOrientation 的值為 1
# 縱向(順時(shí)針旋轉(zhuǎn)180度): SureaceOrientation 的值為 2
# 橫向(順時(shí)針旋轉(zhuǎn)270度): SureaceOrientation 的值為 3
注意: 默認(rèn)0有的為橫向,有的為縱向文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-507854.html
獲取當(dāng)前方向二:
adb shell "dumpsys window displays|grep init="
縱向返回結(jié)果:cur
的值 寬
短 x 高
長(zhǎng)
init=1080x1920 420dpi cur=1080x1920
app=1080x1794 rng=1080x1017-1794x1731
橫向返回結(jié)果:cur
的值 寬
長(zhǎng) x 高
短
init=1080x1920 420dpi cur=1920x1080
app=1794x1080 rng=1080x1017-1794x1731文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-507854.html
旋轉(zhuǎn)屏幕
#禁止旋轉(zhuǎn)
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
#陀螺儀控制
#屏幕翻轉(zhuǎn)
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
#屏幕正常模式
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0
#手動(dòng)
#屏幕翻轉(zhuǎn)
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
#屏幕正常模式
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0
#或者:
#屏幕翻轉(zhuǎn)
adb shell settings put system user_rotation 1
#屏幕正常模式
adb shell settings put system user_rotation 0
到了這里,關(guān)于android 通過(guò)adb shell命令旋轉(zhuǎn)Android屏幕朝向的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!