Android WebView Related properties

Source: Internet
Author: User

1. Set WebView to Transparent:

Android:background= "#00000000" android:cachecolorhint= "#00000000" Webview.setbackgroundcolor (0);

2, WebView display SD card Picture:

Webview.loaddatawithbaseurl (null, "

3. WebView Display string:

Webview.loaddatawithbaseurl ("fake://not/needed", S1, "text/html", "Utf-8", "" ");

4. Set the size of the font shown in WebView:

Public static final textsize[] font_sizes = new textsize[]{textsize.smaller ,textsize.normal,textsize.larger};     private websettings wb;      wb = mwebviewrightcontent.getsettings ();      Wb.settextsize (Font_sizes[ifontsizeid]);  /* Font size:*/public enum textsize {          smallest (),          smaller (         normal),,          larger (         largest),;          textsize (int size)  {              value = size;          }         int value;     } 

5, WebView display the HTML file, to achieve the same effect as the browser displayed on the PC, just set the WebView:

View plaincopy//fit full Screen 39 fit vertical Screen 57 adapt to horizontal screen mwebview.setinitialscale (39); Note: HTML fonts are too small to display on the Android phone or on the development Board is quite small. General 6, 7th font bar!

6. WebView Set the gradient:

Android:fadingedge= "vertical" android:fadingedgelength= "20px"//(vertical, up and down gradient area is 20px)

7. Set WebView to zoom in and out of touch:

Mwebview.getsettings (). Setbuiltinzoomcontrols (True);

8, WebView Double-click to become larger, and then double-click to become small, when manually enlarged, double-click can revert to the original size, the following settings:

Webview.getsettings (). Setusewideviewport (True);

9. Several methods of accelerating webview loading:

//· Increase the priority of rendering webview.getsettings (). setrenderpriority (Renderpriority.high);// Using Webview.getsettings (). Setblocknetworkimage, load the picture at the end to load the render webview.getsettings (). Setblocknetworkimage (True);

10. Convert string to HTML file display:

Gets the string      string sdetails = cursor.getstring (Cursor.getColumnIndex ( "Schinese"));      //intercepts the string by line, storing it in an array      string[] str  = sdetails.split ("\ n");     string s1 =  "";      //iterates through the array and, if the condition is true, adds the set CSS style      for (int i = 0;i  < str.length;i ++) {         if () {Str[i].trim (). StartsWith ("Vt.")) {             str[i] =  "

Android WebView Related properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.