我的html字符串是=

<html><head></head><body><div style='display: inline-flex; background-color: rgb(105, 105, 105); width: 180px; text-align: center;'><div style= 'transform: rotate(11deg); font-weight: 400; height: 35px; text-align: center; font-size: 2em; font-family: caption; color: tomato; text-shadow: 1px 1px turquoise;'> e </div><div style= 'transform: rotate(-6deg); font-weight: 400; text-align: center; color: tan; height: auto; font-family: Georgia; font-size: 3em;'> q </div><div style= 'text-align: center; height: 35px; font-family: Tahoma; font-size: 1.6em; color: rgb(161, 119, 255);'> h </div><div style= 'transform: rotate(-6deg); font-weight: 400; text-align: center; color: tan; height: auto; font-family: Georgia; font-size: 3em;'> o </div><div style= 'transform: rotate(-16deg); color: red; font-weight: 400; height: 35px; text-align: center; font-size: 3em;'> O </div><div style= 'transform: rotate(11deg); font-weight: 400; height: 35px; text-align: center; font-size: 2em; font-family: caption; color: tomato; text-shadow: 1px 1px turquoise;'> b </div></div></body></html>

WebView中未加载此HTML字符串。如果任何人有任何解决方案,请分享…
我的代码是:
String url_captcha="<html><head></head><body><div style='display: inline-flex; background-color: rgb(105, 105, 105); width: 180px; text-align: center;'><div style= 'transform: rotate(11deg); font-weight: 400; height: 35px; text-align: center; font-size: 2em; font-family: caption; color: tomato; text-shadow: 1px 1px turquoise;'> e </div><div style= 'transform: rotate(-6deg); font-weight: 400; text-align: center; color: tan; height: auto; font-family: Georgia; font-size: 3em;'> q </div><div style= 'text-align: center; height: 35px; font-family: Tahoma; font-size: 1.6em; color: rgb(161, 119, 255);'> h </div><div style= 'transform: rotate(-6deg); font-weight: 400; text-align: center; color: tan; height: auto; font-family: Georgia; font-size: 3em;'> o </div><div style= 'transform: rotate(-16deg); color: red; font-weight: 400; height: 35px; text-align: center; font-size: 3em;'> O </div><div style= 'transform: rotate(11deg); font-weight: 400; height: 35px; text-align: center; font-size: 2em; font-family: caption; color: tomato; text-shadow: 1px 1px turquoise;'> b </div></div></body></html>";
    String Url = url_captcha.replace("'", "\"");
    Url = Url.replace("\\", "\\\\");

    captchaAnimation();
    web_Captcha.getSettings().setJavaScriptEnabled(true);
    web_Captcha.loadData(Url, "html/text", "utf-8");

最佳答案

String url_captcha="<html><head></head><body><div style='display: inline-flex; background-color: rgb(105, 105, 105); width: 180px; text-align: center;'><div style= 'transform: rotate(11deg); font-weight: 400; height: 35px; text-align: center; font-size: 2em; font-family: caption; color: tomato; text-shadow: 1px 1px turquoise;'> e </div><div style= 'transform: rotate(-6deg); font-weight: 400; text-align: center; color: tan; height: auto; font-family: Georgia; font-size: 3em;'> q </div><div style= 'text-align: center; height: 35px; font-family: Tahoma; font-size: 1.6em; color: rgb(161, 119, 255);'> h </div><div style= 'transform: rotate(-6deg); font-weight: 400; text-align: center; color: tan; height: auto; font-family: Georgia; font-size: 3em;'> o </div><div style= 'transform: rotate(-16deg); color: red; font-weight: 400; height: 35px; text-align: center; font-size: 3em;'> O </div><div style= 'transform: rotate(11deg); font-weight: 400; height: 35px; text-align: center; font-size: 2em; font-family: caption; color: tomato; text-shadow: 1px 1px turquoise;'> b </div></div></body></html>";
wv.getSettings().setJavaScriptEnabled(true);
    wv.loadDataWithBaseURL(null, url_captcha, "text/html", "utf-8", null);

09-28 09:56