android - 在不同时间在一个图像视图中进行多点触控 Android Studio
问题描述
我正在尝试处理图像上的用户触摸侦听器,我想存储触摸像素的图像视图的所有 XY 坐标。作为这个图像,senario:用户在第一次触摸时触摸图像,我想存储 XY 坐标,然后用户在第二次触摸时触摸相同的图像,我也想存储 XY 坐标等等。手机屏幕
解决方案
希望对您有所帮助!
public class Coordinate {
float x;
float y;
public Coordinate(float x, float y) {
this.x = x;
this.y = y;
}
}
ArrayList<Coordinate> coordinates = new ArrayList<>();
yourImageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//int eventAction = event.getAction();
//switch (eventAction) {
// case MotionEvent.ACTION_DOWN:
// break;
// case MotionEvent.ACTION_UP:
// break;
// case MotionEvent.ACTION_MOVE:
// break;
//}
coordinates.add(new Coordinate(event.getX(), event.getY()));
return false;
}
});
推荐阅读
- wireguard - 如何强制wireguard立即握手?
- uber-api - Uber Eats Api - 更新项目端点返回 404
- python - 将元组列表重组为浮点列表
- reactjs - 对未转换为 localIdentName 的 Storybook 连接字符串做出反应
- c# - 无法在 UDP 端口上捕获消息
- group-by - 如何同时加入、求和和分组
- sql - 为什么我无法运行 SQL Server 2019 setup.exe 文件?
- amazon-web-services - 403 禁止在 API 网关上使用自定义域的附加域
- python - 如果字典在 Python 中为空,则刷新 api 查询
- python - git post-receive 挂钩未触发 Jenkins 作业(机器 1:本地,机器 2:远程)