0

I'm trying to get a code to zoom in images implemented with ViewPager in Universal Image Loader. I've tried these but none is what I want:

Someone knows a code to zoom in ViewPager? thanks

Community
  • 1
  • 1
Charlie
  • 325
  • 1
  • 7
  • 22

2 Answers2

3

ScrollingViewPager.java https://gist.github.com/slightfoot/5475083

Once added to your project use that extended ViewPager in your layouts instead of the support library one. Then you can use https://github.com/MikeOrtiz/TouchImageView and just add implements ScrollingViewPager.CanScrollCompat to his TouchImageView to make it compatible and your done.

Simon
  • 10,932
  • 50
  • 49
  • implementing all the above, I found difficulty when I zoom and drag on a image the view pager scrolls to next item – Asif Sb Sep 22 '16 at 06:44
1

The easiest way to implement zoom in android is using the WebView.

Place web view in each page of your ViewPager.

And do something like this:

public static String zoomHTML = "<!DOCTYPE html>\n" +
        "<html>\n" +
        "<head><title>Zoom Image</title></head>\n" +
        "<body>\n" +
        "<div>\n" +
        "    <img width=\"%d\" height=\"%d\" id=\"myCanvas\" src=\"data:image/png;base64,%s\"></img>\n" +
        "</div>\n" +
        "</body>\n" +
        "</html>";




String data = String.format(zoomHTML, screenHeight, screenWidth, base64StringImage);

zoomWebView.getSettings().setBuiltInZoomControls(true);
zoomWebView.getSettings().setSupportZoom(true);
zoomWebView.setInitialScale(100);
zoomWebView.loadDataWithBaseURL("", data, "text/html", "UTF-8", "");
Sergey Neskoromny
  • 1,188
  • 8
  • 15