bvanvelsen - ACA Group
bvanvelsen - ACA Group

Reputation: 1751

How to get WebView to ignore css

I am trying to load a local HTML page in an Android Webview. This page contains some layouting using CSS. But I also noticed that the Webview has a setBackgroundColor() method in which you can set a background color. however this does not work when the CSS file also set a background color.

Does anyone know how to make the Android Webview to ignore these CSS style when I set my own background color?

Upvotes: 0

Views: 534

Answers (1)

ePeace
ePeace

Reputation: 1997

What you could do is add style to your page with javascript:

webview.loadUrl("javascript:document.body.style.background = color;");

Call this after you have loaded your url or html.

PS I think if you ignored the CSS you would the get the default white background even if you set setBackGroundColor()

setBackGroundColor is a method that all Views have, that's the only reason WebView has it imo.

Upvotes: 1

Related Questions