Android的图像浏览类支持捏缩放和滚动 [英] Android ImageViewer class supporting Pinch-Zoom and Scrolling
问题描述
我在寻找,在我的应用程序对于一个给定的URI(已经存储在我的应用程序在一个安全的地方通过Web服务获取的影像)打开一个图像的图像浏览库。我真的很喜欢三星Galaxy S图像浏览-活动,因为它使用捏变焦和滚动垂直/水平。此外,它缩放图片速度非常快在我的三星手机:)
I am searching an ImageViewer library that opens an image in my application for a given URI (the image fetched by a webservice is already stored within my application in a secured place). I really like the "Samsung Galaxy S" ImageViewer-Activity because it uses pinch-zoom and "scrolling" vertical/horizontal. Also it scales the picture very fast on my samsung phone :)
我知道,我可以像这样的意图打开一个图像:
I know that I can open an image with an intent like this:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(uri, "image/*");
startActivity(i);
最适合的浏览器被称为,当没有找到一个ActivityNotFoundException提高。所以,这就是酷!
The best suitable viewer is being called, when none is found an ActivityNotFoundException is raised. So thats cool!
但问题是,我不能与外部意图(出于安全目的),打开一个图像。即:用户应该不会有posibility通过菜单选项保存打开的图像,以他的外置SD卡或发送此图片到其他服务(电子邮件/ Twitter或左右)。所以,我写我自己的图像浏览级(活动),只能在我的应用程序被称为... 可惜我不是很熟练变换图像,因此没有任何开源项目(或库)覆盖该用例?
But the problem is that I am not allowed to open an image with an external intent (for security purposes). i.e: The user should not have the posibility to save the opened image via a menu option to his external sd-card or send this picture to another service (email/twitter or s.o.). So I have to write my own ImageViewer-Class (Activity) that can only be called within my application... Unfortunately I am not very skilled transforming images, so is there any open source project (or library) that covers this use case?
我已经要求谷歌,发现这个 HTTP://$c$c.google.com/ P / Android的捏/ 但它没有很好地工作(也它没有滚动功能)。
I already asked google and found this one http://code.google.com/p/android-pinch/ but it didnt work very well (also it has no scroll-functionality).
感谢您的建议:)
推荐答案
要处理图像的最简单方法是使用的WebView
,如果图像存储本地或某处在线。的WebView支持捏放大等功能。
The easiest way to handle images is using a WebView
, if the image is stored local or somewhere online. WebView supports pinch to zoom and other functions.
Java的例子:
String imageUrl = "file:///local/dir/image.jpg"; // http://example.com/image.jpg
WebView wv = (WebView) findViewById(R.id.yourwebview);
wv.getSettings().setBuiltInZoomControls(true);
wv.loadUrl(imageUrl);
XML源代码:
XML source:
<WebView android:id="@+id/yourwebview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
这篇关于Android的图像浏览类支持捏缩放和滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!