Android Question Webview and pinch to zoom of big images

ldb68

Member
Licensed User
Longtime User
If I open the html page into the android browser (2.36 ) I can perform the pinch to zoom while maintaining the image to the size reached ( even on the Nexus 7 android 4.3 with crome) and reverse to orignal size.

With a webview the image is always reported as the% setted in html page when I do a pinch to zoom.
How can I have the default behavior of the browser?

TEST CODE
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
WebView1.Initialize("WebView1")
Activity.AddView(WebView1, 0,0, 100%x, 100%y)
WebView1.LoadUrl("http://www.webdomino.it/image.html")

HTML PAGE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<div style="margin:auto;" align="center" >
test1
<br />
<img border="0" src="sky.jpg" style="width:80%;" ></img>
<br />
test2
</div>
</body>
</html>


thanks
 

ldb68

Member
Licensed User
Longtime User
Can anyone confirm that the behavior of a webview with pinch to zoom on a picture (style="width:80%;") does not work as in the native Android browser?
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Same thing happens to my phone, I guess this is the expected behavior. Still, I'm a bit surprised, I will get to alter your html, and see if something better can be achieved. I know that it's the style causing the behavior, but let's see...
 
Upvote 0

ldb68

Member
Licensed User
Longtime User
Same thing happens to my phone, I guess this is the expected behavior. Still, I'm a bit surprised, I will get to alter your html, and see if something better can be achieved. I know that it's the style causing the behavior, but let's see...

The strange thing is that the native Android browser has a different behavior and obviously better.
Try to pinch to zoom the image ...
This is the behavior that is expected.
But WebView is not mapped on native android object??
 
Upvote 0

ldb68

Member
Licensed User
Longtime User
WebView wraps the native WebView object.
Hi Erel
Why webview has a behavior so different from Android browser?
I need to show images that are larger than the screen, and if I don't set an adaptation for the image (style = "width: xx% ) there is no way to view the entire image.
Reflection library did not solves the problem because then pinch to zoom does not allow reduce the image scaled.
The native Android browser works perfectly as I need.
Can I solve the problem?
thanks
 
Upvote 0

ldb68

Member
Licensed User
Longtime User
This is how the native WebView behaves.
This means that the native Android browser is not using a webview to render html pages?
There is no other way to get a similar result?

it is quite frustrating.
With IOS have native support for PDF (with links and gesture) and also the equivalent of the webview behaves like a normal browser (pinch to zoom it's ok).

thanks
 
Upvote 0

ldb68

Member
Licensed User
Longtime User
The problem here is that the image is center aligned and the margin is set to auto. So it is expected to always be centered and fit the screen.

Why don't you set the image link directly?

If I don't set a initial image % width (e.g. style = "width: 100%' ) a big image is not completely showed in the webview and with pinch to zoom I can not reduce the image to fit the screen.
That's the problem.
The Android native browser override the style when doing pinch to zoom (in and out).

I try to make a simple app with Delphi XE5 for Android to see if I get the same result with the WebView.
Today I report the results

thanks
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…