在 Android Webview 问题中加载内联 CSS

Loading inline CSS in Android Webview problem

我正在开发一个基于 android webview 的应用程序 - HTML、CSS 和 Javascript 是动态构建的 - 我以前做过这个,但是将 运行疯狂的问题。当 css 开始在 webview 中加载时,它会在 # 颜色处停止加载 - CSS 构建如下:

    String h1 =
            ".sexy_line{\n" +
                    "    display:block;\n" +
                    "    border:none;\n" +
                    "    color:transparent;\n" +
                    "    height:6px;\n" +
                    "    background:black;\n" +
                    "    background: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 450, from(#2626ff), to(#ffffff00));\n" +
                    "}\n"   +
                    ".floatBottom\n" +
                    "     {\n" +
                    "     position: absolute; \n" +
                    "     bottom: 0;\n" +
                    "     }\n";
return h1;
}

它确实在以下位置停止加载:

background: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 450, from(

环境:

Android: 平板电脑 7.1.1 开发环境:Android Studio 3.5.3

任何帮助将不胜感激 --- 谢谢

更新:我正在使用以下方法加载页面:

 wv = findViewById(R.id.idWebView);            
 settings.setDefaultTextEncodingName("utf-8");
 wv.loadData(webInterface,"text/html","UTF-8");

更新目标 SDK 后遇到同样的问题。 通过 base64 编码我的 HTML 然后在编码中传递它 base64 解决了这个问题:

// instructions is the HTML string   

 webView.loadData(Base64.encodeToString(instructions.getBytes(), Base64.DEFAULT), "text/html", "base64");

请在此处勾选文档中的蓝框: WebView.loadData

blue box