class WebUtils{ companion object { fun Uri(web : WebView?,s: String?) { web!!.loadUrl(s!!) web!!.webViewClient = WebViewClient() web!!.settings.javaScriptEnabled = true web!!.settings.javaScriptCanOpenWindowsAutomatically = true web!!.settings.useWideViewPort = true web!!.settings.loadWithOverviewMode = true web!!.settings.allowFileAccess = true web!!.settings.defaultTextEncodingName = "utf-8" web!!.settings.setSupportZoom(true) web!!.settings.builtInZoomControls = true web!!.settings.displayZoomControls = false web!!.settings.cacheMode = WebSettings.LOAD_DEFAULT web!!.settings.mediaPlaybackRequiresUserGesture = false } } }
在asset文件打开本地网页
class MainActivity(){
WebUtils.Uri(frag.web,"file:///android_asset/Rain/DMY.html")
}