Note that there are some explanatory texts on larger screens.

plurals
  1. POMonodroid Transparent WebView
    text
    copied!<p>I'm trying to re-write a java android app into monodroid, however I have come across an issue with the background transparency of the webview that I use to display the contents of each screen.</p> <p>This code works correctly on the java version (Black text on a green background), but in the C# version, the webview's background is black (black rectangle on the green background).</p> <p><strong>Java Code:</strong></p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(getApplicationContext()); layout.setBackgroundColor(Color.GREEN); WebView webView = new WebView(getApplicationContext()); layout.addView(webView); setContentView(layout); webView.getSettings().setJavaScriptEnabled(true); webView.setBackgroundColor(Color.TRANSPARENT); webView.loadData("&lt;html&gt;&lt;body style='background-color: transparent;'&gt;" + "Some text...&lt;/body&gt;&lt;/html&gt;", "text/html", "UTF-8"); } </code></pre> <p><strong>C# Code:</strong></p> <pre><code>protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var layout = new LinearLayout(ApplicationContext); layout.SetBackgroundColor(Color.Green); var webView = new WebView(ApplicationContext); layout.AddView(webView); SetContentView(layout); webView.Settings.JavaScriptEnabled = true; webView.SetBackgroundColor(Android.Resource.Color.Transparent); webView.LoadData("&lt;html&gt;&lt;body style='background-color: transparent;'&gt;" + "Some text...&lt;/body&gt;&lt;/html&gt;", "text/html", "UTF-8"); } </code></pre> <p>I know that there are similar issues that people where having, but they usually were that java version not working. My C# is having the problems though...</p> <p>I am using the default project template in both cases.</p> <p>What am I forgetting or not doing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload