1. 程式人生 > >騰訊瀏覽器核心替換android原生webview

騰訊瀏覽器核心替換android原生webview

1.下載騰訊瀏覽器服務jar包,放進libs.下載地址

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


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用發.