如何使用adb滚动应用程序?

10

我正在寻找一种使用adb在不同类型的应用中向上或向下滚动的方法。

我该如何使用adb命令滚动Facebook或CNN等应用程序?

3个回答

24

向上滚动:

adb shell input swipe 300 300 500 1000 

向下滚动:

adb shell input swipe 500 1000 300 300 

如果您需要更精确的滑动,可以调整坐标。

sleep 2

在进行下一个命令之前,也要加上睡眠时间。


11
您可以使用 input 命令。
使用方法:
adb shell input swipe <start_x> <start_y> <end_x> <end_y> duration_ms>

所以,要向下滚动(向上滑动):
adb shell input swipe 250 800 250 400 300 

向上滚动(向下滑动):

adb shell input swipe 250 400 250 800 300 

请确保您使用的坐标在您设备屏幕尺寸范围内!

您可以通过截屏来确定正确的坐标:

adb exec-out screencap -p > screen.png

2
你可以使用 adb 输入 shell 命令 roll
adb shell input roll <dx> <dy>

例子:

adb shell input roll 15 15

请尝试以易于理解的方式回答问题,以便用户能够轻松地理解。 如果您想在答案中添加代码部分,请使用编辑菜单中的代码块。 谢谢并继续努力。 - Muhammad Zahab

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接