Webview skid

AlpVir

Well-Known Member
Licensed User
Longtime User
My device (480x854 pixels) is set to portrait mode.
I load a locale page HTML into a WebView.

B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim h  As String 
   Dim NomeFile  As String 
   Activity.LoadLayout("HelpHtml")
    Activity.Title = "AIUTO"
   WebView1.Initialize("WebView1")
   Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
   NomeFile="Mio_taccuino_per_android.htm"
   h = ReadTextReader (NomeFile) 
   WebView1.LoadHtml(h)
End Sub

The page HTML is a table with width set to 470 pixel

B4X:
<table border="0" cellpadding="0" cellspacing="0" style="font-size: 12 px; font-family: Arial" width="470">

Vertical scrolling is perfect.
Horizontal scrolling "swerves" to the right or left of a few tens of pixels, almost as if the page was about 800 or 900 pixels wide.
What parameters should I set the WebView for easy operation ?
I would not be possible in practice that scroll horizontally.
Thanks
 

warwound

Expert
Licensed User
Longtime User
Hi again.

I think the first thing you should do is set the width of your table to 100%:

B4X:
<table border="0" cellpadding="0" cellspacing="0" style="font-size: 12 px; font-family: Arial" width="100%">

Now look at adding a viewport meta tag to your webpage.

HTML5 Rocks - "Mobifying" Your HTML5 Site

Targeting Screens from Web Apps | Android Developers

Those links will give you some info about the viewport meta tag.
You'll probably want to experiment with the viewport width and initial-scale attributes.

Martin.
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
As before you hit the problem perfectly: with the "100%" everything was resolved. I was foolish not to think of it before.
Thanks also for the 2 links but for now do not intend to investigate these argument. It 'just about a month I use the language B4a !
Thank you again.
Ugo
 
Upvote 0
Top