Home » Android » android – Change Background color and font color

android – Change Background color and font color

Posted by: admin June 15, 2020 Leave a comment

Questions:

I want to change my WebView‘s background color and font size.

How to&Answers:

Assuming that you have defined your webview in an XML layout resource you can do the following:

WebView myWebView = (WebView) findViewById(R.id.myWebView);
myWebView.setBackgroundColor(Color.parseColor("#000000"));
myWebView.getSettings.setDefaultFontSize(10);

You may also want to enable javascript and create a simple WebClient to handle page loading

Hope it helps!

Answer:

You could call some javascript that would modify the CSS of the loaded page.

Answer:

I would think you can’t – unless you control the html data displayed.

The font and background are controlled by the html data feed to the Webview and not the Webview itself.