首页 > 代码库 > Android -- Webview自适应屏幕

Android -- Webview自适应屏幕

第一种                                                                                         

WebSetting settings = webView.getSettings();settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

把所有内容放在webview等宽的一列中。(可能会出现页面中链接失效)

第二种                                                                                         

settings.setUseWideViewPort(true);settings.setLoadWithOverviewMode(true);

第三种                                                                                         

DisplayMetrics metrics = new DisplayMetrics();     getWindowManager().getDefaultDisplay().getMetrics(metrics);     int mDensity = metrics.densityDpi;www.2cto.com      if (mDensity == 120) {               settings.setDefaultZoom(ZoomDensity.CLOSE);          }else if (mDensity == 160) {               settings.setDefaultZoom(ZoomDensity.MEDIUM);          }else if (mDensity == 240) {               settings.setDefaultZoom(ZoomDensity.FAR);          }

我是天王盖地虎的分割线