Skip to main content

Android WebView

This post contain all about android webview.
If you are reading this I assume that you know what is webview and just want to use it in your app.



To Use web view you need to first you need to add the webview in your layout

#1 Add webview to layout


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/webview">

    <WebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/wview" />
</LinearLayout>

#2 Find the webview
To use the webview you need to find the widget in your activity class.


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public class AboutActivity extends AppCompatActivity {

    WebView wview;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about);

        //find the webview
        wview = (WebView)findViewById(R.id.wview);

    }


}

#3 Load local file to webview
copy your html file in android "assets" folder and pass the html file to loadURL method


1
2
//load the local file from webview
            wview.loadUrl("file///android_asset/aboutm.html");

Comments

Popular posts from this blog

Xamarin : Simple Calculator Tutorial Visual Studio C#

Simple Calculator in Android (Xamarin) using VisualStudio C#In Brief: This article will help you on building a simple calculator in android Xamarin with simple steps using C# Language in Visual Studio. Detail:
Building this simple calculator will let you learn how to work with the Android Buttons, Text View and simple functions. The UI is not so beautiful but is a great way to learn the basic functionalities.

Create Custom View in android MATRIX EFFECT CANVAS tutorial

Create Custom View in android MATRIX EFFECT CANVAS tutorial
Hi all as I stared my development with android I always wanted to create a Custom view or rather I want a canvas where I can draw freely. To learn about canvas I decided to create matrix rain effect which I can add to my android layout. Here is the complete tutorial which I have post. Hopping it will be use full to someone.

You can find the link to android project at the bottom of the post

Android Live Wallpaper Tutorial


Hi, at last I was able to create my own live wallpaper " MATRIX RAIN ". 

Download : click here

The matrix rain effect which I am using is the same which I created in canvas.
ref :- http://www.androidlearner.com/2016/09/create-custom-view-in-android-matrix.html
I this post I will describe how I put together the live wallpaper.