How to make an app WebView in android (with source code)


Download APK Download Source Code Contact Us

Step1:­ Create new project in Android Studio.

How to make an app WebView in android
How to make an app WebView in android

What is WebView?

WebView is a view that dispaly web page inside your application. You can also specify HTML
string and can show it inside your application using WebView.

Step 2:­ You must add the internet permissions to your AndroidManifest file.

How to make an app WebView in android

step 3:­ Adding a WebView to your Application.

<WebView> element to your xml layout file.

Ex:­<?xml version="1.0" encoding="utf­8"?>

<WebView xmlns:android=""





Step 4:­ Accessing the WebView from code.

How to make an app WebView in android

Step 5:­ Loading the url into the WebView.

Load Web page in the WebView,use loadurl().
EX:­WebView myWebView = (WebView) findViewById(;

How to make an app WebView in android

Step:6­ Enabling JavaScript in the WebVIew.

By default the Android WebView component has JavaScript disabled. You can enable through the WebSetting attached to your WebView.

Ex:­WebView myWebView = (WebView) findViewById(;

WebSettings webSettings = myWebView.getSettings();


setMinimumFontSize(int size):­ Set the minimum font size. The default is 8.


setMediaPlaybackRequiresGesture(boolean require):­ Set whether the WebView requires a user

gesture to play media. The default is true.

webSettings. setMediaPlaybackRequiresGesture();

setTextZoom(int textZoom):­ Set the text zoom of the page in percent. The default is 100.


Step:7­ Handling Page Navigation.

When the user click a link in the web page loaded into the WebView.the default behaviour is to load that URL of the link in the system Android browser.

To open links clicked by the user, simply provide a WebViewClient for your WebView, using


Ex:­WebView myWebView = (WebView) findViewById(;

myWebView.setWebViewClient(new WebViewClient());

private class MyWebViewClient extends WebViewClient {


public boolean shouldOverrideUrlLoading(WebView webView, String url) {

return false;



How to make an app WebView in android

Download APK Download Source Code Contact Us

Posted in All Tutorials, Android Tutorials | Tagged | Leave a comment

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered By: