In recent project development, using WebView to load HTML pages saves a lot of time on page development and also accelerates project progress.
We need to display product reviews, page design is as follows:
To invoke the Android code, the settings for WebView are as follows:
Webview.getsettings (). setjavascriptenabled (true); Webview.getsettings (). Setbuiltinzoomcontrols ( true); Webview.getsettings (). Setlayoutalgorithm (Layoutalgorithm.single_column); Webview.getsettings (). Setdefaulttextencodingname ("UTF-8");
There is a problem when presenting the data. The actual results are as follows:
Here the logistics speed and product quality can not be displayed.
The key code for HTML is as follows:
Switch(Jsonforcreat.data[i]. Qualitylevel) { Case' 1 ': $("#q" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 515px"); Break; Case' 2 ': $("#q" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 535px"); Break; Case' 3 ': $("#q" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 555px"); Break; Case' 4 ': $("#q" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 575px"); Break; Case' 5 ': $("#q" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 595px"); Break; default : $("#q" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 595px"); Break; } Switch(Jsonforcreat.data[i]. Speedlevel) { Case' 1 ': $("#s" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 515px"); Break; Case' 2 ': $("#s" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 535px"); Break; Case' 3 ': $("#s" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 555px"); Break; Case' 4 ': $("#s" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 575px"); Break; Case' 5 ': $("#s" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 595px"); Break; default : $("#s" +jsonforcreat.data[i]. key_id). CSS ("background-position", "0px 595px"); Break; }
After careful comparison of all data formats, compare iOS, Discover:
The same HTML page, the same data, the page on iOS is normal, on Android is unable to display the logistics speed and product quality evaluation star number.
At the end of the WebView setting, the WebView property
Webview.getsettings (). Setlayoutalgorithm (Layoutalgorithm.single_column);
After commenting out, I found that the display is normal.
Inquiry information:
Single_column: Put everything in a wide column such as the WebView component.
This attribute is unclear as to why it conflicts with HTML display, and it is also hoped that some cows will be able to answer them.
Android HTML with WebView property from conflict