如何在Android中创建自定义webview?

Jim*_*mmy 5 android webview

我有扩展webview的类(MyCustomWebView)我可以这样做吗?

<MyCustomWebView 
    android:id="@+id/myCustomWebView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>
Run Code Online (Sandbox Code Playgroud)

如果没有,我可以做这样的事情.

WebView webView = (WebView) findViewById(R.id.webview);
webView = new MyCustomWebView(this);
Run Code Online (Sandbox Code Playgroud)

Kar*_*hik 15

是的,你可以这样做:

    <your.package.MyCustomWebView android:id="@+id/myCustomWebView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />
Run Code Online (Sandbox Code Playgroud)

然后在代码中你可以这样做:

MyCustomWebView myWebView = (MyCustomWebView) findViewById(R.id.myCustomWebView);
Run Code Online (Sandbox Code Playgroud)