How can I get zoom functionality for images?


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:

  1. overwriting ImageView, that seems a little bit too much for such a common problem.
  2. using a webview but with less control over the overall layout etc.
3/29/2010 10:36:30 AM

Accepted Answer

I used a WebView and loaded the image from the memory via


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 ;)

8/18/2010 3:15:50 PM


I've just given TouchImageView a new update. It now includes Double Tap Zoom and Fling in addition to Panning and Pinch Zoom. The code below is very dated. You can check out the github project to get the latest code.


Place in your project. It can then be used the same as ImageView. Example:

TouchImageView img = (TouchImageView) findViewById(;

If you are using TouchImageView in xml, then you must provide the full package name, because it is a custom view. Example:

    android:layout_height="match_parent" />

Note: I've removed my prior answer, which included some very old code and now link straight to the most updated code on github.


If you are interested in putting TouchImageView in a ViewPager, refer to this answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow