简体   繁体   English

查看可滚动,可缩放,可点击图像?

[英]View for scrollable, zoomable, clickable image?

I need to show an image which is actually a map with coloured areas, also I need to be able to: 1. zoom in and out using two fingers 2. scroll the image as it is bigger than screen 3. clicks on the image, get clicked area pixel value(color), so that I know which area the user clicks 我需要显示实际上是带有彩色区域的地图的图像,还需要:1.用两根手指放大和缩小2.滚动图像,使其比屏幕大3.单击图像,获取点击区域的像素值(颜色),这样我就知道用户点击了哪个区域

I searched many hours, tried many approaches: 1. Write a class that extends View, and display a Bitmap, I found a thread in the forum about it, but there is no zoom, and the scroll is not natural. 我搜索了许多小时,尝试了许多方法:1.编写一个扩展View并显示位图的类,我在论坛中找到了一个有关它的线程,但是没有缩放,滚动也不自然。 2. Use a WebView to display HTML file that contains the image, so there is zoom and scroll functionalities, however, I cannot control the limit of zoom in/out, also, when the user clicks, I'm not sure if I can get the position on the image map by adding scrollX, scrollY with touchX, touchY. 2.使用WebView显示包含图像的HTML文件,因此具有缩放和滚动功能,但是,我无法控制放大/缩小的限制,而且,当用户单击时,我不确定是否可以通过将scrollX,scrollY与touchX,touchY相加来获取图像地图上的位置。 As the image may be scaled up/down, also, there may be paddings that WebView adds to its content. 由于图像可能会按比例放大/缩小,因此,WebView可能会向其内容添加填充。

This really drives me crazy, can anyone help? 这真让我发疯,有人可以帮忙吗?

您可以查看http://code.google.com/p/android-pinch/ :这提供了一个视图,该视图应支持缩放。

I believe you can create an instance of this for your WebView. 我相信您可以为此 WebView创建一个实例。 From what I've been reading, the WebView is the correct way to do it. 从我一直阅读的内容来看,WebView是正确的方法。 Finding ways to control zoom is all you have to do and ScaleGestureDetector seems to provide the functions to allow you to do so. 寻找控制缩放的方法只是您要做的,ScaleGestureDetector似乎提供了允许您执行此操作的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM