webview layout problems

zxxdaro

Member
Licensed User
Longtime User
I am having trouble understanding the workings of webviews.
I have set up a layout with the designer and I then call the webview like this.

Activity.LoadLayout("mylayout")
WebViewr1.Initialize("WebViewr1")
Activity.AddView(WebViewr1,0,0,180,150)

What is clear is that this overwrites the webview that the layout sets up.

For example if I change the last line to
Activity.AddView(WebViewr1,0,0,100%x,100%y)
I get a webview which completely fills the phone's screen.

I need to know how I reference the webview in the layout without overwriting it.
 

NJDude

Expert
Licensed User
Longtime User
If you create views using the designer you DO NOT have to initialize them in your code.

So, assuming you have a webview named WebView1 created in the designer (and also Generated Members), and you want to fill the screen you should do something like this:
B4X:
Activity.LoadLayout("mylayout")

WebView1.Width = 100%x
WebView1.Height = 100%y
 
Upvote 0
Top