如何在ImageView上定义一些可点击区域(类似HTML图像映射)?

huangapple go评论68阅读模式
英文:

How to define some clickable areas on ImageView (like HTML image map)

问题

Sure, here's the translated content:

假设我有一个显示学校地图的 ImageView:
如何在ImageView上定义一些可点击区域(类似HTML图像映射)?

我想要在图像上定义一些可点击的区域(类似于 HTML 图像地图),类似于以下方式:

Point musicRoom = new Point(30,70);
Point schoolGarden = new Point(120, 80);
Point library = new Point(60, 50);
Point cafeteria = new Point(60, 40);
Point mainOffice = new Point(70, 60);

然后,我可以处理每个点的点击事件,例如,如果点击了 musicRoom 点,将显示一个 Toast。或者如果点击了 schoolGarden 点,将启动另一个活动。

是否有一个库可以轻松实现这个功能?我尝试了 ClickcableImagesAreas

implementation 'com.github.Lukle:ClickableAreasImages:v0.1'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'

但无法编译,因为该库似乎依赖于一个旧的、硬编码的 PhotoView 库。
如何在ImageView上定义一些可点击区域(类似HTML图像映射)?

英文:

Let's say I have an ImageView displaying a school map:
如何在ImageView上定义一些可点击区域(类似HTML图像映射)?

I want to define some clickable regions on the image (like HTML image map), something like this:

Point musicRoom = new Point(30,70);
Point schoolGarden = new Point(120, 80);
Point library = new Point(60, 50);
Point cafetaria = new Point(60, 40);
Point mainOffice = new Point(70, 60);

Then I can handle the click events on each point, e.g is musicRoom poins is clicked, a Toast will appear. Or if schoolGarden point is clicked, another activity will be started.

Is there a library to easily achive this? I tried ClickcableImagesAreas:

implementation 'com.github.Lukle:ClickableAreasImages:v0.1'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'

Doesn't compile because the library seems to depend on an old, hardcoded PhotoView library
如何在ImageView上定义一些可点击区域(类似HTML图像映射)?

答案1

得分: 1

你可以使用 imagemap.io 平台来解决这个问题。在那里,你可以为可点击区域添加工具提示。
你可以在这里找到一个示例 https://imagemap.io/examples/demo-product

英文:

You can use just imagemap.io platform to solve this issue. There you can add tooltips for your clickable area.
You can find an example here https://imagemap.io/examples/demo-product

huangapple
  • 本文由 发表于 2023年5月6日 23:37:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189735.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定