Android Question Webview doesn't fit on the screen

Baris Karadeniz

Active Member
Licensed User
I have an iOS webview app. I used "scaled to fit" in iOS and it works good. But in android, there is no such property. I used horizontal and vertical anchors as BOTH. But it didn't work. I wrote;

WebView1.width = 100%x
WebView1.height= 100%y

to the script in visual designer, it didn't work too. What should I do?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
If you want the WebView to completely fill the screen then you need to make sure that all the distances are 0:

SS-2016-05-07_21.28.57.png


My guess is that the problem is not with the WebView but with its content.

Try this (add a reference to JavaObject library):
B4X:
Dim jo As JavaObject = WebView1
jo.RunMethod("setInitialScale", Array(1))
 
Upvote 0

Baris Karadeniz

Active Member
Licensed User
I selected Java Object library and wrote the above statements in to the Sub Globals. But "setInitialScale" is red and there is a message in log.
 
Upvote 0

Baris Karadeniz

Active Member
Licensed User
Sorry. It is not red but the statement below is written in the log;

This sub should only be used for variables declaration or assignments of primitive values. (warning #29)

What should I do?
 
Upvote 0

Baris Karadeniz

Active Member
Licensed User
Unfortunately webview doesn't fit on the screen with the above codes too. There is another method given below with webviewsettings. It works. But when I zoom in, view goes to right but doesn't go to the left.

B4X:
Dim WebViewSettings1 As WebViewSettings
WebViewSettings1.setDefaultZoom(WebView1, "FAR")
WebViewSettings1.setLoadWithOverviewMode(WebView1, True)
WebViewSettings1.setUseWideViewPort(WebView1, True)
WebViewSettings1.setAllowFileAccess(WebView1, True)

Is there any other better solution?
 
Upvote 0
Top