Android WebView to load html garbage problem

Symptoms:

webview.loadUrl("http://www.xxx.com")

with

WebView.loadUrl("file:///android_asset/knowledge/memory.html")  

Load Html files garbled

Solution:

1. Set html file header utf-8;

 <head>
    <title>这是标题</title>
    <meta name="content-type" content="text/html; charset=utf-8">
    <meta http-equlv="Content-Type" content="text/html;charset=utf-8">
</head>

2. html webView holding encoding setting set which encode

webview.getSettings().setDefaultTextEncodingName("utf-8"); 

Guess you like

Origin www.cnblogs.com/renhui/p/11428900.html