I want to change my WebView
's background color and font size.
To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.
Go to Design > Page Color. Choose the color you want under Theme Colors or Standard Colors. If you don't see the color you want, select More Colors, and then choose a color from the Colors box.
Answer: The font colour option, when enabled in a text, changes the Colour of the font itself. I.e. the letters will change their color as selected whereas, the Text highlight colour option doesn't changes the font colour, instead the background colour of the text changes.
Simply add the appropriate CSS selector and define the color property with the value you want. For example, say you want to change the color of all paragraphs on your site to navy. Then you'd add p {color: #000080; } to the head section of your HTML file.
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!
You could call some javascript that would modify the CSS of the loaded page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With