I know how to display an image that is bigger than the screen. That’s fairly simple and explained in details here, however, this method makes you able to scroll as far as you want, event if you have left the image and you just have black screen. I would like to know how we can make the scrolling stop when we reach the side of the picture…
Share
Load your image into a WebView. Then you will get all the scroll behaviors you are looking for, and even the default zoom controls if you choose to turn them on…practically for free. Your only other option (to my knowledge) would be to used the 2D graphics APIs (Canvas, etc.) and create your own version of drawing tiles (like viewing a section of a map).
If your image is local, take a look at this example of reading local image data in from the SD Card. The cleaner approach to serving a local image in this case would be to create a ContentProvider and access the resource through a content:// URL in your WebView.
Example using the bundled image
car.jpgin theassetsdirectory of your project:res/layout/main.xml
src/ImageViewer.java
For an image bundled with your project, that’s the simplest method. This does not work with images in your resources directory (like res/drawable). That path is not worth the code required to complete it.