in Android Code Tips

WebView: Change background and font color

In order to change a WebView’s background color there is a standard way:

mWebView.setBackgroundColor(Color.Black);

In order to change a WebView’s text font color there is no standard way:
Either you change the font through the html code, or you do this:

htmlData="<font color='black'>" + htmlData + "</font>";
mWebView.loadDataWithBaseURL(null, htmlData, "text/html", "UTF-8", null);
Share