My Xamarin WebView was not displaying my HTML correctly. Even though it was set to fill the whole screen, the body height in the HTML remained at 0px.
In addition, I had a div in the HTML with the following style:
position:absolute; top:0px; bottom:0px; left:0px; right:0px;
This div was also 0px high.
I attempted various options, such as:
webView.SetInitialScale(1);
webView.Settings.LoadWithOverviewMode = true;
webView.Settings.UseWideViewPort = true;
However, none of these solutions worked. It came to my attention that webView.LayoutParameters.Height was -2 for some unknown reason.
Once I implemented the following code snippet, the absolutely positioned div suddenly had a height:
protected override void OnSizeChanged(int w, int h, int oldw, int oldh) {
webView.LayoutParameters.Height = -1;
base.OnSizeChanged(w, h, oldw, oldh);
}
The question arises: why did changing the Layout Parameter to -1 cause the HTML to render correctly?