在webview中看不到Html字符串

时间:2016-04-20 09:55:02

标签: android webview

我的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>

此Html字符串未在webview中加载。如果有任何人有任何解决方案,请分享......

我的代码是:

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");

1 个答案:

答案 0 :(得分:2)

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);
相关问题