Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a custom webview in Android?

I have class (MyCustomWebView) that extend webview can i do something like this ?

<MyCustomWebView 
    android:id="@+id/myCustomWebView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

if not, could i do something like this.

WebView webView = (WebView) findViewById(R.id.webview);
webView = new MyCustomWebView(this);
like image 561
Jimmy Avatar asked Dec 22 '11 03:12

Jimmy


People also ask

What is custom WebView?

Extensions. opensource, custom-webview.

What can I use instead of WebView?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.

Is Android WebView same as Chrome?

No, Chrome for Android is separate from WebView. They're both based on the same code, including a common JavaScript engine and rendering engine.


1 Answers

Yes, you can do this:

    <your.package.MyCustomWebView android:id="@+id/myCustomWebView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

Then in code you can do this:

MyCustomWebView myWebView = (MyCustomWebView) findViewById(R.id.myCustomWebView);
like image 73
Karthik Avatar answered Sep 21 '22 22:09

Karthik