Reputation: 253
I want to perform scroll using Accessibility service and i am doing this
public boolean scrollView(AccessibilityNodeInfo nodeInfo) {
if (nodeInfo == null) return false;
if (nodeInfo.isScrollable()) {
return nodeInfo.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
}
for (int i = 0; i < nodeInfo.getChildCount(); i++) {
if (scrollView(nodeInfo.getChild(i)) {
return true;
}
}
return false; }
But problem is when there are four option to perform up,down left and right it performs left and right but i want to perform up and down there also. like in facebook app it scroll on top section where notifications and news feed are.But not on page. is there any way to scroll where is focus of user.
Upvotes: 3
Views: 6676
Reputation: 18870
You're probably scrolling the wrong container. There are likely multiple views in your heirarchy that are "scrollable". Try finding different scrollable views within your heirarchy.
Also, in Android M they added APIs to do things like specifically scroll different directions. So, if you are in fact on the correct View, you can scroll in different directions using these actions instead:
ACTION_SCROLL_FORWARD
ACTION_SCROLL_LEFT
ACTION_SCROLL_RIGHT
etc.
Upvotes: 1