0

Does anyone know if there's a means to have a webview open with an image completely visible (full-size) initially? The images in question are larger than the screen resolution so they would be scaled with a bar where the scales don't match. When I set:

    zoomView.getSettings().setLoadWithOverviewMode(true);
    zoomView.getSettings().setSupportZoom(true);
    zoomView.getSettings().setUseWideViewPort(true);

I get the image zoomed to the max width, leaving some scrolling necessary at max zoom (can't see the whole image).

Ideally I'd love to just use the built-in Honeycomb gallery3d functionality, but unfortunately I can't find the source to see how they pull that off.

Akram
  • 7,548
  • 8
  • 45
  • 72
Anthony
  • 7,638
  • 3
  • 38
  • 71

2 Answers2

0

Try setting Webview's LayoutAlgorithm to SINGLE_COLUMN. This will resize only those images with Width greater than the width of the device. This won't help you with images smaller than the screen.

webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

Link: Can Android's WebView automatically resize huge images?

Community
  • 1
  • 1
Sheharyar
  • 73,588
  • 21
  • 168
  • 215
  • SINGLE_COLUMN is deprecated, and if used hyperlinks do not work. – Pointer Null Mar 23 '13 at 16:00
  • 1
    SINGLE_COLUMN might be deprecated, but it's the only way without using CSS. BTW I checked it out, and Hyperlinks are working fine. Tested on Nexus 7 (4.1) and Galaxy Nexus (4.0, 4.1, 4.2). – Sheharyar Mar 23 '13 at 22:02
  • 2
    Some links work, some don't, maybe it's dependent on complexity of HTML, maybe dependent on Android version. But that's proven. Don't be surprised when your customers start to complain. – Pointer Null Mar 25 '13 at 13:30
0

Don't use setUseWideViewPort - it loads the WebView completely zoomed out. You just have to edit max-width of elements in your HTML

AndrewS
  • 7,418
  • 8
  • 35
  • 50