在Android webview onTouch事件中获取图像的实际图像坐标

发布于 2024-11-26 11:18:21 字数 331 浏览 0 评论 0原文

我正在将平面图加载到 Android 应用程序中。我需要用户只需单击一下即可识别平面图上的问题区域。我的思考过程是识别点击操作,重新加载 webview 的 html,将我的标记资源添加到指定位置。

我已将图像加载到网络视图中以利用缩放功能。我可以获取发生点击的 webview 的 X,Y 坐标,但我不知道如何获取当前的缩放级别。另外,我不确定将 X、Y、比例转换为实际像素坐标需要什么数学运算。

webview 是我使用的正确视图吗?

编辑: 使用下面建议的链接,我可以使用缩放功能。我仍然不知道如何在 TouchImageView 顶部放置一个可绘制标记,更不用说获取图像上实际触摸的坐标了。

I'm loading floor plans into an Android application. I need the user to be able to identify problem areas on the floor plan with a single click. My thought process is to identify the click action, reload the html of the webview adding my marker asset to it at the specified location.

I've loaded the image into a webview to take advantage of zoom capabilities. I can get the X,Y coordinates of the webview where the click occurred, but I can't figure out how to get the current zoom level. Also, I'm not sure what math will be required to translate the X,Y,scale to actual pixel coordinates.

Is the webview the right view for me to use?

EDIT:
Using the link suggested below, I got the zoom functionality working. I still can't figure out how to place a drawable marker on top of the TouchImageView, much less get the coordinates that were actually touched on the image.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳哥哥 2024-12-03 11:18:21

对于您的缩放问题以及 coor,如何获得缩放功能images? 应该对您有帮助

接受的答案确实使用了 WebView,但另一个答案使用了更好的方法来启用缩放。它还提供将 X 和 Y 坐标转换为可用点所需的必要数学运算。

For your zoom question as well as coor, How can I get zoom functionality for images? should help you

The accepted answer does use a WebView, but the other answer uses a better approach for enabling zoom. It also provides the necessary math required for translating your X and Y coordinates into usable points.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文