【发布时间】:2023-03-15 04:50:01
【问题描述】:
我使用 onTouch() 记录一个手势的所有点,但 StrokeDescription 有一个持续时间。持续时间越短,我能看到的手势越粗糙。当我执行它时,它不是我记录的点。
然后我看到了 continueStroke 方法。看起来可以仔细设置每个周期的时间,但它不起作用。
谁能举个使用 continueStroke 方法的例子?谢谢。
@RequiresApi(api = Build.VERSION_CODES.O)
static public GestureDescription CreateGestureDescription(){
Path dragRightPath = new Path();
dragRightPath.moveTo(200, 200);
dragRightPath.lineTo(400, 200);
long dragRightDuration = 500L; // 0.5 second
Path dragDownPath = new Path();
dragDownPath.moveTo(400, 200);
dragDownPath.lineTo(400, 400);
long dragDownDuration = 500L;
GestureDescription.StrokeDescription rightThenDownDrag =
new GestureDescription.StrokeDescription(dragRightPath, 0L,
dragRightDuration, true);
rightThenDownDrag.continueStroke(dragDownPath, dragRightDuration,
dragDownDuration, false);
GestureDescription.Builder clickBuilder = new GestureDescription.Builder();
return clickBuilder.addStroke(rightThenDownDrag).build();
}
【问题讨论】:
标签: android