Android Webview code in android studio and fully explained with CodeVUs.
First of all, For Creation WebView in Android Studio.We need an android studio that builds android applications and then Follows these Steps:
1. Create A Android Studio Project new Project
Select Empty Activity And Create.
Click On Finish Button.
2.Go to activityMain.xlm file
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"/>
Copy this Code and paste it into XML Relative Layout.
3. After Pasting XML code in XML file then copy this Code and past it into MainActivity.java
WebView webView;
url= "PAST YOUR URL";
webView=findViewById(R.id.webview);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setWebViewClient(new WebViewClient(){
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
webView.setVisibility(View.GONE);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
webView.setVisibility(View.VISIBLE);
}
});
webView.loadUrl(url);
4. Replace Your URL with "PAST YOUR URL"
5. Go to the manifests file and Past this user permission
<uses-permission android:name="android.permission.INTERNET" />
After Run Android Studio Project
Professional Programmers team that helps you to code your program in any language and any platform. Regards CODEVUS Team!