On Mon, Apr 11, 2011 at 1:42 PM, Jake Basile <[email protected]> wrote:
> I am writing an image viewer that downloads a PNG from a remote server,
> saves it to storage, and then opens it in a WebView so that I get
> multi-touch zoom for free. These images are usually going to be documents,
> so the user will want to be able to zoom in very far. I am sending down
> images of sufficient resolution to enable this, but the WebView seems to be
> "helping" me by scaling my image to the screen size to start out with. This
> means that my image is much too low resolution to be properly zoomed in on.
>
> I have searched around for this, and I have found some other people
> encountering a similar problem, but the only possible solution I found was
> to cut the image up into tiles and reassemble them using HTML before loading
> it in the view. This seems like a kludge, and I am asking if anyone has
> either a way to turn off that scaling, or an alternative method to get what
> I need.
>
> The code that initializes the WebView:
>
> viewer = (WebView)findViewById(R.id.activity_imageviewer_webview);
> viewer.setBackgroundColor(0);
> WebSettings settings = viewer.getSettings();
> settings.setJavaScriptEnabled(false);
> settings.setBuiltInZoomControls(true);
> settings.setUseWideViewPort(true);
> settings.setLoadWithOverviewMode(true);
>
> The code that loads the image into the WebView:
>
> viewer.loadUrl(Uri.fromFile(imageFile).toString());

If the image is big enough to warrant zooming, it might well be too
big for your heap space, in which case you'd need to tile it, anyway.

Beyond that, I would think it would be simpler just to implement your
own zoom logic on an ImageView:

http://blogs.sonyericsson.com/developerworld/category/tutorials/zoom/
http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-6-implementing-the-pinch-zoom-gesture/1847
http://stackoverflow.com/questions/3055133/android-multitouch-image-zooming/3059280#3059280

or use existing multi-touch-enabled widgets:

http://code.google.com/p/android-pinch/

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.6 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to