最近一些设备停止运行webview组件,我检测到android 8和android 6或更少的版本都能正常工作,但在android 7 o 9的设备中没有显示文本。这个问题开始于最近的几周。自2018年2月以来我还没有更新应用程序
descripcion = (WebView) findViewById(R.id.txt_descripcion);
String description="<html><body><head><style type=\"text/css\">\n" +
"p {\n" +
"font-size:90%;text-indent: 1em; text-align:justify; \n" +
"}\n" +"body {font-family: Arial, Helvetica, sans-serif;}\n" +
"\n" +
"table { font-family: \"Lucida Sans Unicode\", \"Lucida Grande\", Sans-Serif;\n" +
" font-size: 12px; width: 100%; text-align: left; border-collapse: collapse; }\n" +
"\n" +
"th { font-size: 13px; font-weight: normal; background: #b9c9fe;\n" +
" border-top: 4px solid #aabcfe; border-bottom: 1px solid #fff; color: #039; }\n" +
"\n" +
"td { background: #e8edff; border-bottom: 1px solid #fff;\n" +
" color: #669; border-top: 1px solid transparent; }\n" +
"\n" +
"tr:hover td { background: #d0dafd; color: #339; }"+
"</style></head><p>"+hechizo.getDescripcion()+"</p></body></html>";
descripcion.loadData(description,"text/html; charset=UTF-8",null);
答案 0 :(得分:1)
尝试一下:
WebSettings settings = myWebView.getSettings();
settings.setDefaultTextEncodingName("utf-8");
myWebView.loadDataWithBaseURL(null, htmlString, "text/html", "utf-8", null);
答案 1 :(得分:0)
工程,您知道为什么loadData错误了吗?