Reputation: 1422
Let's say I want to open Google's homepage inside a WebView with a custom css.
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("http://www.google.com");
How can I change the background color to black after page is fully loaded?
Upvotes: 1
Views: 1015
Reputation: 2859
Using Javascript injection, you can load a page and change the class styles by reloading it with a custom Javascript. For example:
view.loadUrl("your.website.com");
view.loadUrl("javascript:document.getElementsByClassName('navbar')[0].style.backgroundColor='black';");
Upvotes: 4