android webview 常用设置 - 记录

来源:互联网 发布:刀具路径模拟软件 编辑:程序博客网 时间:2024/06/06 03:58

使用webview时的一些基本设置:

WebSettings setting = mWebView.getSettings();setting.setJavaScriptEnabled(true)//设置webview 自适应屏幕setting.setUseWideViewPort(true);setting.setLoadWithOverviewMode(true);setting.setBuiltInZoomControls(false);//关闭放大/缩小按钮setting.setDisplayZoomControls(false);//开启远程调试, 需要系统版本>=4.4WebView.setWebContentsDebuggingEnabled(true);

会话共享设置
当我们的app 中有嵌入webview时,可以使用以下代码与APP的会话进行共享

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){            CookieSyncManager.createInstance(context);        }CookieManager cookieManager = CookieManager.getInstance();cookieManager.setCookie(url, cookieString);
0 0
原创粉丝点击