some WebView Questions

mjtaryan

Active Member
Licensed User
Longtime User
I recall reading somewhere that WebView is the only view that has zoom capabilities. Is that correct? If not, what other views have this feature?

How is the zoom "level" calculated? Is there any way to set the zoom level's initial value?

How is wordwrap controlled or enabled/disabled when zooming (I''ve seen some sites where the page redraws and others where it doesn't)?

How is an html file loaded (I assume "openhtml* is used, but is the syntax)? What headers are needed in the html file?

I may have additional questions as my work progresses. Thanks for the help.
 

mjtaryan

Active Member
Licensed User
Longtime User
Thanks but I read that documentation before posting this thread . I found no answers to the specific questions I''ve asked here.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
I recall reading somewhere that WebView is the only view that has zoom capabilities. Is that correct? If not, what other views have this feature?
That is correct.

How is the zoom "level" calculated? Is there any way to set the zoom level's initial value?
Check the documentation, you'll find how to set up the ZOOM level.

How is wordwrap controlled or enabled/disabled when zooming (I''ve seen some sites where the page redraws and others where it doesn't)?
That depends on the site or HTML not the WebView.

How is an html file loaded (I assume "openhtml* is used, but is the syntax)? What headers are needed in the html file?
That's also in the documentation under LoadHTML.
 
Upvote 0

mjtaryan

Active Member
Licensed User
Longtime User
That is correct.
OK.

Check the documentation, you'll find how to set up the ZOOM level.
The documentation says NOTHING about zoom levels, that is how much the page is zoomed + or -. The only thing it mentions about zoom are:

Zoom (In As Boolean) As Boolean
Zooms in or out according to the value of In. Returns true if zoom has changed.

ZoomEnabled As Boolean Gets or sets whether the internal zoom feature is enabled. The zoom feature is enabled by default.

That depends on the site or HTML not the WebView.
OK.

That's also in the documentation under LoadHTML.
The example used in the documentation is for an image file. What about a text file or an html file?
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
OK.


The documentation says NOTHING about zoom levels, that is how much the page is zoomed + or -. The only thing it mentions about zoom are:

Zoom (In As Boolean) As Boolean
Zooms in or out according to the value of In. Returns true if zoom has changed.

ZoomEnabled As Boolean Gets or sets whether the internal zoom feature is enabled. The zoom feature is enabled by default.


OK.


The example used in the documentation is for an image file. What about a text file or an html file?

Don't you hate it when people give you answers which aren't any answer at all?

The answer is...

You can use the WebViewXtender library's setInitialScale() function

I have version 1.50.

You'd use it like this:

B4X:
sub process_globals
   Dim wvX As WebViewXtender
end sub

sub globals
  Dim TheWebView as Webview
end sub

Dim ZoomPercent As Int

ZoomPercent = 200

wvX.setInitialScale(TheWebView,ZoomPercent)

Note that it is called the WebViewExtended library; but when you pick it to Dim it it will say WebViewExtender (I wish people would stay consistent).

You can also look at the scale value:

wvX.getScale(TheWebView) ' as Float

You'll notice a strange thing, though. Having to do with inconsistencies... when you set it, it's a percentage. When you get it, it's a fraction. So, if you are going to use that value to set it again... you have to remember that and change a fraction like .25 into a percentage by multiplying by 100, or to go in the other direction, dividing by 100. Makes you wonder why the guy didn't just keep it as being both type Float with a fractional number. Probably because the Android functions were like that. Anyways...

Strange, but it works. Just cast the values correctly.

So, the reason the documentation didn't say anything about it is - it doesn't allow that; thus the reason you have to use another library to get that ability.

You probably don't need that information any more; but someone will.
 
Upvote 0
Top