Is there a common way to show a big image and enable the user to zoom in and out and pan the image?
Until now I found two ways:
I used a WebView and loaded the image from the memory via
webview.loadUrl("file://...")
The WebView handles all the panning zooming and scrolling. If you use wrap_content the webview won't be bigger then the image and no white areas are shown. The WebView is the better ImageView ;)
I'm using the same approach. I have a large subway map that I want the user to be able to zoom and scroll around. I noticed though that if you have a quite large image (i.e. 1000 or 3000 pixels wide), the image gets blurry once you zoom in. It seems coliris cannot display a large zoomed image very sharp. Even though the original image is uncompressed and very sharp. Therefore I ended up cutting the one large image into smaller slices and putting them together again via HTML. This way the image stays sharp when zooming in. (I'm on Nexus One, 2.1update before and now on 2.2)
@Mathias Lin: if a large image is sent over the wire, i've heard carriers compress large images. will this use-case suit you or did you load the image locally.
@Sam Quest: loading it locally
much better to use webview's built in zoom buttons and support for pinch to zoom in/out than to write a completely new algo which may not work across different phones and future android platform releases
this solution can only be applied if you happen to have the image sitting around on disk, or the image is small enough such that you can base 64 encode is and pass the string value into loadUrlWithData().