如何滚动accessibilitynodeinfo?

时间:2016-04-04 08:29:19

标签: android scroll accessibilityservice

我正在使用AccessibilityService API为三方应用程序构建accessiblity服务。但我不知道如何向后滚动accessibilitynodeinfo?你能帮助我吗? node.perform(AccessibilityNodeInfo.ACTION_SCROLL_BACKSCROLL)不起作用。

1 个答案:

答案 0 :(得分:0)

我相信这就是你想要的:

void scrollBackward(AccessibilityNodeInfo) throws NotScrollable {

    while (node != null) {

        if (node.isScrollable()) {
            node.performAction(ACTION_SCROLL_BACKWARD);
            return;
        }

        node = node.getParent();

    }

    throw new NotScrollable("This node cannot be scrolled");
} 

注意:我正在手机上打字,所以请原谅我,如果不能完全编译的话。它应该非常接近。