欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > Android >内容正文

Android

android模拟手指滑动,Android Accessibility 模拟界面滑动

发布时间:2025/4/5 Android 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 android模拟手指滑动,Android Accessibility 模拟界面滑动 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

1 Accessibility配置请查看https://blog.csdn.net/qq_27885521/article/details/102910188

2 绘制path

Path mPath = new Path();//线性的path代表手势路径,点代表按下,封闭的没用

//x y坐标 下面例子是往下滑动界面

mPath.moveTo(100,200);//代表从哪个点开始滑动

mPath.lineTo(100,100);//滑动到哪个点

3 模拟绘制手势

MainService.mainService.dispatchGesture(new GestureDescription.Builder().addStroke(new GestureDescription.StrokeDescription

(mPath, 20, 500)).build(), new AccessibilityService.GestureResultCallback() {

@Override

public void onCompleted(GestureDescription gestureDescription) {

super.onCompleted(gestureDescription);

Toast.makeText(TransparentActivity.this, "模拟手势成功", Toast.LENGTH_SHORT).show();

}

@Override

public void onCancelled(GestureDescription gestureDescription) {

super.onCancelled(gestureDescription);

Toast.makeText(TransparentActivity.this, "模拟手势失败",Toast.LENGTH_SHORT).show();

}

}, null);

总结

以上是生活随笔为你收集整理的android模拟手指滑动,Android Accessibility 模拟界面滑动的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。