Reputation: 97
I am developing an androind webview based application - the HTML, CSS and Javascript is built dynamically - I have done this before but have run into a insanely madding problem. when the css starts loading in webview it stops loading at the # color - The CSS build is as follows:
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;
}
it literally stops loading at:
background: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 450, from(
Environment:
Android: Tablet 7.1.1 Development Environment: Android Studio 3.5.3
Any help would be greatly appreciated --- Thank you
an update: i am loading the page with the following method:
wv = findViewById(R.id.idWebView);
settings.setDefaultTextEncodingName("utf-8");
wv.loadData(webInterface,"text/html","UTF-8");
Upvotes: 0
Views: 1289
Reputation: 46
Was facing the same issue after I updated my target SDK.
Solved this by base64 encoding my HTML and then passing it base64
in encoding:
// instructions is the HTML string
webView.loadData(Base64.encodeToString(instructions.getBytes(), Base64.DEFAULT), "text/html", "base64");
Please check the blue box in the documentation, here: WebView.loadData
Upvotes: 3