问题是手势分配不正确。并非所有点都被刷过。
我试图进行矩形滑动。如果持续时间长,则调度的不是完美的,而是几乎完美的。
[这是我从https://codelabs.developers.google.com/codelabs/developing-android-a11y-service/#0使用的内容
private void configureSwipeButton() {
Button swipeButton = (Button) mLayout.findViewById(R.id.swipe);
swipeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Thread.sleep(1000);
GestureDescription.Builder gestureBuilder = new GestureDescription.Builder();
Path swipePath = new Path();
swipePath.moveTo(500, 500);
swipePath.lineTo(900, 500);
swipePath.lineTo(900, 900);
swipePath.lineTo(500, 900);
swipePath.lineTo(500, 500);
gestureBuilder.addStroke(new GestureDescription.StrokeDescription(swipePath, 0, 1500));
dispatchGesture(gestureBuilder.build(), null, null);
}
catch(Exception ex){
Toast.makeText(view.getContext(),ex.getMessage(),Toast.LENGTH_LONG).show();
}
}
});
}
我尝试在素描应用程序上执行此操作:https://play.google.com/store/apps/details?id=com.sonymobile.sketch&hl=en
这是1500年持续时间的结果:https://prntscr.com/odq1cn
以下是持续时间1000的结果:https://prntscr.com/odq2qj
以下是持续时间500的结果:https://prntscr.com/odq2xs
以下是持续时间100的结果:https://prntscr.com/odq3li
问题是手势分配不正确。并非所有要点都被刷过。我试图进行矩形滑动。如果持续时间长,则调度的不是完美的,而是几乎完美的。这就是...
我认为这实际上取决于手机的速度,因此无法解决此问题。