腾讯浏览器内核替换android原生webview

1.下载腾讯浏览器服务jar包,放进libs.下载地址

http://res.imtt.qq.com/TES/tbs_sdk_thirdapp_v3.0.0.1038_43000_1485049870479.zip

腾讯浏览器内核替换android原生webview_第1张图片

2.在xml文件中加入webview

<com.tencent.smtt.sdk.WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="400dp"/>

3.主要是websetting和原生webview有点区别

mWebview = findViewById(R.id.webview);
mWebview.loadUrl("http://119.23.63.140/shop");
WebSettings settings = mWebview.getSettings();
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(true);
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
settings.setSupportZoom(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setGeolocationEnabled(true);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
其他设置可参考原生webview用发.

你可能感兴趣的:(Android开发)