How to transparent Android WebView

Standard

First of all you have to make a transparent background in html code:

String webData = StringHelper.addSlashes("<!DOCTYPE html>
<head>
<meta http-equiv=\"Content-Type\" " +
 "content=\"text/html; charset=utf-8\"> 
</head>
<body>
<div style=\"background-color: rgba(0,0,0,1.0); ">
 your webpage details...
</div>
</body>
</html>");

and then:

webView = (WebView) findViewById(R.id.webview);
webView.setBackgroundColor(0);
webView.loadData(webData, "text/html", "UTF-8");

Leave a Reply

Your email address will not be published. Required fields are marked *