Webview - scrolling sideways?

boten

Active Member
Licensed User
Longtime User
When loading a "wide" web page with the built-in browser on the phone, I can scroll left/right (and of course up/down) in order to see the entire width of the page, but loading the same page into WebView I can only scroll up/down.

Is there a way to make webview scroll sideways too?
 

boten

Active Member
Licensed User
Longtime User
Thanks Erel, There's nothing like a working example to set one on the RIGHT track!
The problem was in the HTML file (in Hebrew) which has

<table align=right> tag.

The solution of course is to get the entire file via HttpRequest, remove the "align=right" and use webview.loadhtml.
Will test it & report.
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
Here's the problem:
The Html files I want to show are generated somewhere else in this format:
B4X:
<html>
<HEAD>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=visual">
<title>header</title>
</HEAD>
<BODY>
<table align=right>
<tr>
<td><font size=-1><pre>
[I]....
.... text lines produced by an old DOS (!!!) program 
.... as a .prn file. They contain a "rude" table
.... done with - | +
.... and contains both English, numbers, and Hebrew
..... hence the html are in "visual hebrew"
....[/I]
</pre>
</font>
</td></tr></table></body></html>
1) using webview.LoadUrl on this file does NOT scroll left/right.
2) A test version of same file but with <table> (without align=right) is scolling fine left/right
3) Since the files are generated elsewhere, they can NOT be changed to <table>

So I tried to read the file and manipulate it:
4) Reading the entire file with HttpClient and Str=HttpResponse.GetString("ISO-8859-8")
5) replace <table align=right> with <table> in Str
6) use webview.LoadHtml(Str)

This result in a the Hebrew being reversed. This is true even when step 5 is not done.
Somehow getting the entire file into a string nullifies the effect of charset=visual (even tried to Str.replace "visual" with the other options for hebrew with no effect)

Any ideas?
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
Webview - scrolling sideways - status report

Status Update 31/10/2011:

To dispaly Hebrew HTML files which contain <table align=right> and do NOT scroll sideways, the solution is:

1) Get the entire HTML source code (encoding=ISO-8859-8)
2) Replace <table align=right> with <table>
3) Write the modified source code to an internal file using encoding=ISO-8859-8
4) LoadUrl(the internal file)

B4X:
Sub HttpClient_ResponseSuccess (Response As HttpResponse, TaskId As Int)
  source = Response.GetString("ISO-8859-8") 
  source=source.Replace("<table align=right>","<table>")
  If File.Exists(File.DirInternal,"aa.htm") Then File.Delete(File.DirInternal,"aa.htm")
   
  Dim Writer1 As TextWriter
  Writer1.Initialize2(File.OpenOutput(File.DirInternal, "aa.htm", False),"ISO-8859-8")
  Writer1.WriteLine(s)
  Writer1.Close 
  webv.LoadUrl("file:///" & File.DirInternal & "/aa.htm")
End Sub

Still lurking problem: Display the page in MONOSPACE font (how?)
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
The Html contains <pre> tag that should cause the text to display in fixed-font.
On the PC browser it shows in fixed-font (monospace) but on the phone's browser it shows in proportional-font.
Adding the <style> tag (in the <table> tag or in the <Head> tag) didn't make any difference, it still shows in proportional-font. Also tried to use <code> tag, still proportional-font.
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
I finally tricked the <pre> tag to work on WebView.

Since the html need to be modified in any case (replace <table align=right> with <table>), and be written to DirInternal (see this post), I applied one more modification:
I replaced <HEAD> with
B4X:
<HEAD>
<style type='text/css'>
 @font-face {font-family: 'cour'; src: url('cour.ttf'); }
 pre {font-family:cour;color:#000000;}
</style>
and copied the monospace font cour.ttf to DirInternal on Activity_Create (if it isn't there already)
 
Upvote 0
Top