webview加载一个界面后,在onPageFinished中加入修改页面字体颜色css,如下String nightCode = ""; try { InputStream is = getResources().openRawResource(R.raw.day); byte[] buffer; buffer = new byte[is.available()]; is.read(buffer); is.close(); nightCode = Base64.encodeToString(buffer, Base64.NO_WRAP); } catch (IOException e) { e.printStackTrace(); } mWeb.loadUrl("javascript:(function() {" + "var parent = document.getElementsByTagName('head').item(0);" + "var style = document.createElement('style');" + "style.type = 'text/css';" + "style.innerHTML = window.atob('" + nightCode + "');" + "parent.appendChild(style)" + "})();"); 加载完成后,每次都是先显示原来的页面,过一秒左右在页面所有字体颜色都修改了,有什么办法显示页面之前就替换好字体颜色,先谢谢各位了。
倚天杖
相关分类