1, webview load webpage
1, Webview.loadurl (); Directly display the content of the Web page (display the network picture separately), usually does not appear garbled. 2, Webview.loaddata (data, "text/html", "UTF-8"); LoadData is primarily designed to load data in URI format, and it cannot load content over the network. Online WebView loaded Chinese garbled, mostly using this method. There are two main problems in using the process: (1) loaddata cannot load picture content, and if you want to load the picture content or get more powerful web support, it is recommended to use a more powerful loaddatawithbaseurl. (2) Many practical loaddata methods of friends have encountered the problem of garbled display, that is due to incorrect encoder settings. We know that the string type of data is mainly Unicode encoding, and webview generally to save resources using UTF-8 encoding, so we have to tell the method how to Transcode when LoadData. That is to tell it to turn Unicode encoded content into UTF-8 encoded content. Some friends, although the encoding method in the LoadData, but still garbled, this is because the text encoding of WebView also need to specify the encoding. For example, the following:webview wv = (WebView) Findviewbyid (R.id.webview) ;wv.getsettings (). Setdefaulttextencodingname ("Utf -8") ;wv.loaddata (content, "text/html", "UTF-8") ; Note for gb2312 or GBK (3). Page description encoding format <meta http-equiv= "Content-type" content= "text/html;charset=gb2312" > above two methods are online to give a better method, but I have not tried to solve my garbled problem. Originally I used LoadData method to parse HTML, but it is said that this is an official bug, can not be used to parse Chinese. So go around its path, using Loaddatawithbaseurl method, where Codeingtype is set to Utf-8 OK. 3, where BaseURL for you to store the path of the photos, such as:
2, webview background transparent:
Setting android:background in the XML file is not valid.
<webview
Android:id= "@+id/big_data_detail_content_textview"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:textcolor= "#fff"
android:background= "@drawable/color_transparent"
Android:textsize= "14DP"/>
Workaround:
Webview.setbackgroundcolor (0); Set Background transparency
Garbled problems with Android WebView