英文:
How to define some clickable areas on ImageView (like HTML image map)
问题
Sure, here's the translated content:
假设我有一个显示学校地图的 ImageView:
我想要在图像上定义一些可点击的区域(类似于 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 库。
英文:
Let's say I have an ImageView displaying a school map:
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
答案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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论