0

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");
2
  • Just realized that css stops loading anytime there is a # in the CSS script. Commented Jan 21, 2020 at 20:04
  • Question, has anyone notices a webview problem in SDK Re; 29. When i went back to 25 everything seemed to work perfectly. is this a know problem Commented Jan 22, 2020 at 16:27

1 Answer 1

3

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

blue box

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.