当前位置:编程学习 > 网站相关 >>

WebView自适应

[java]
WebSettings settings = wv_content.getSettings(); 
         
        DisplayMetrics metrics = new DisplayMetrics(); 
        getWindowManager().getDefaultDisplay().getMetrics(metrics); 
        int mDensity = metrics.densityDpi; 
        if (mDensity == 120) { 
        settings.setDefaultZoom(ZoomDensity.CLOSE); 
        }else if (mDensity == 160) { 
        settings.setDefaultZoom(ZoomDensity.MEDIUM); 
        }else if (mDensity == 240) { 
        settings.setDefaultZoom(ZoomDensity.FAR); 
        } 

WebSettings settings = wv_content.getSettings();
  
  DisplayMetrics metrics = new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(metrics);
  int mDensity = metrics.densityDpi;
  if (mDensity == 120) {
  settings.setDefaultZoom(ZoomDensity.CLOSE);
  }else if (mDensity == 160) {
  settings.setDefaultZoom(ZoomDensity.MEDIUM);
  }else if (mDensity == 240) {
  settings.setDefaultZoom(ZoomDensity.FAR);
  }


注:stackoverflow看到的

 

补充:Web开发 , 其他 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,