[Begginer] Android WebView

Hello, this post is intended to answer my friend question about how to use WebView in Android application using Android Studio. First of all, WebView is a?View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.

Note that, in order for your Activity to access the Internet and load web pages in a WebView, you must add the INTERNET permissions to your Android Manifest file:

  • Create New Project in Android Studio, if you have already in a Project just create new Module.
  • In layout activity_main.xml use

This basically, add RelativeLayout contains WebView and ProgressBar.

  • In MainActivity.java, we get the webview object and manipulated as a minimal web browser, just to load a simple URL address.

And here the result webview loading this post.

tutorial-webview
 
You can also load data from local assets inside android app, for more documentation about how to use WebView you can look at WebView Android Documentation.

 

Leave a Reply

Your email address will not be published. Required fields are marked *