content: package my.project.silisili.main.webview.normal;
  
  import android.annotation.SuppressLint;
  import android.content.Context;
  import android.util.AttributeSet;
  import android.webkit.WebSettings;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  
  public class NormalWebView extends WebView {
      public final static String PC_USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36";
      public final static String PHONE_USER_AGENT = "Mozilla/5.0 (Linux; Android 9; ONEPLUS A6010 Build/PKQ1.180716.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.158 Mobile Safari/537.36";
      private WebViewClient client = new WebViewClient() {
          // 防止加载网页时调起系统浏览器
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
              view.loadUrl(url);
              return true;
          }
      };
  
      public NormalWebView(Context arg0) {
          super(arg0);
          setBackgroundColor(85621);
      }
      @SuppressLint("SetJavaScriptEnabled")
      public NormalWebView(Context arg0, AttributeSet arg1) {
          super(arg0, arg1);
          this.setWebViewClient(client);
          // this.setWebChromeClient(chromeClient);
          // WebStorage webStorage = WebStorage.getInstance();
          initWebViewSettings();
          this.setClickable(true);
      }
  
      private void initWebViewSettings() {
          WebSettings webSetting = this.getSettings();
          webSetting.setJavaScriptEnabled(true);
          webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
          webSetting.setAllowFileAccess(false);
          webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
          webSetting.setSupportZoom(false);
          webSetting.setBuiltInZoomControls(false);
          webSetting.setUseWideViewPort(true);
          webSetting.setSupportMultipleWindows(true);
          // webSetting.setLoadWithOverviewMode(true);
          webSetting.setAppCacheEnabled(true);
          //是否调节内容 是否全屏
          webSetting.setLoadWithOverviewMode(true);
          // webSetting.setDatabaseEnabled(true);
          webSetting.setDomStorageEnabled(true);
          webSetting.setGeolocationEnabled(false);
          webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
          // webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
          webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
          // webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
          webSetting.setCacheMode(WebSettings.LOAD_NO_CACHE);
          webSetting.setUserAgentString(PC_USER_AGENT);
      }
  
  }
  