Javatpoint Logo
Javatpoint Logo

Kotlin Android WebView

Android WebView is a view component which displays the web pages in the application. It uses a WebKit engine to show the web pages. The android.webkit.WebView class is the subclass of AbsoluteLayout class.

The loadUrl() and loadData() methods of WebView are used to load and display the web pages. To learn more about Android WebView go to

There are different ways to load the web page in WebView such as:

Load the HTML content as a string in the class:

Load the web page (.html, .jsp, etc.) from within the application. In such case, web pages are placed in assets directory.

Load the web URL inside WebView as:

Kotlin Android WebView Example

In this example, we will load the web URL in the WebView component and override the URL.

Directory structure

Kotlin Android WebView


Add the WebView component in the activity_main.xml file.


In the AndroidMenifest.xml file, add the Internet permission to connect the network connection.


Add the following code in the MainActivity.kt class. In this class, we are using the loadUrl() method of WebView to load web URL.

Create a MyWebViewClient class that extends the WebViewClient that override the shouldOverrideUrlLoading() method.


Kotlin Android WebView
Next Topic#

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA