1
votes

I am completely lost as to why this HTML is not working within a WebView on Android within Xamarin. It's been a hair pulling experience trying to get something this simple working.

The HTML source is as below. I would expect the screen to go blue, but it stays orange:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>MyTitle</title>
    <style>
        body {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
            height: 100%;
            background: orange;
        }

        .fullScreenDiv {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
            height: 100%;
            background-color: blue;
        }
    </style>
</head>
<body>
    <div id='myId' class='fullScreenDiv'> </div>
</body>
</html>

A few things I have looked into:

Elements

Below is the code containing the WebView init.

if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Kitkat)
{
    WebView.SetWebContentsDebuggingEnabled(true);
}

webView = new Android.Webkit.WebView(this.Context);

webView.Settings.JavaScriptEnabled = true;

webView.SetWebViewClient(new Client(this));
webView.SetWebChromeClient(new ChromeClient());

webView.SetLayerType(LayerType.Software, null);

webView.Settings.UseWideViewPort = true;
webView.Settings.LoadWithOverviewMode = true;

webView.LoadUrl("file:///android_asset/View.html");

var x = webView.IsHardwareAccelerated; // returns false

Any ideas or pointers please?

1
Show the layout file containing the WebView - Squonk
Squonk, I just modified the question to clarify the fact that it is using Xamarin. I will attempt to extract the important parts of the code and add them in. - Blueberry
Added. Please let me know if there's any other info that would be useful. - Blueberry
Sorry I don't know anything about Xamarin. I was expecting you to have a standard XML layout file for your Activity content. If Xamarin doesn't use those then I can't give any help. - Squonk
I will try to reproduce in a standard XML layout. May at least narrow down the issue. Thanks! - Blueberry

1 Answers

-1
votes

We ( WizRocket) faced similar issue recently & solved it. The details are here http://blog.wizrocket.com/2015/03/05/androids-webview-is-broken/