My Life with Android
Introduction Android Componets UserInterface Advanced UI Data Storage Advanced Concepts Others New Studio

Webview

Android WebView is used to display web page in android. The web page can be loaded from same application or URL. It is used to display online content in android activity.
Android WebView uses webkit engine to display web page.
The loadUrl() and loadData() methods of Android WebView class are used to load and display web page.

1. From Online

WebView mywebview = (WebView) findViewById(R.id.webView1);  
mywebview.loadUrl("http://www.google.com/");

2.From Application Resource

WebView mywebview = (WebView) findViewById(R.id.webView1);  
mywebview.loadUrl("file:///android_asset/myresource.html");

3.From String Resource


String data = "<html><body><h1>Hello, Android</h1></body></html>";  
mywebview.loadData(data, "text/html", "UTF-8");  

Supported Html Tags:
  • <a> (supports attributes "href")
  • <annotation>
  • <b>
  • <big>
  • <font> (supports attributes "height", "size", "fgcolor" and "bicolor", as integers)
  • <i>
  • <li>
  • <marquee>
  • <small>
  • <strike>
  • <sub>
  • <sup>
  • <tt>
  • <u>

    • Display HTML Conttent in Textview :
      You need to use Html.fromHtml() to display HTML content.
      Ex : myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));

Android - Layout