Java Code Examples for android.webkit.WebSettings#setUseWideViewPort()

The following examples show how to use android.webkit.WebSettings#setUseWideViewPort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArticleInfoDetailFragment.java    From travelguide with Apache License 2.0 6 votes vote down vote up
@Override
public void onPageFinished(WebView view, String url)
{
  super.onPageFinished(view, url);

  // Fix java.lang.NullPointerException at:
  // android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:71)
  final Context context = getActivity();
  if (shouldAnimate(url, context))
  {
    Utils.fadeOut(context, mProgressContainer);
    Utils.fadeIn(context, mWebView);
  }

  // If picture enable zoom, else disable
  final WebSettings ws = mWebView.getSettings();

  final boolean isPicture = Utils.isPictUrl(url);
  ws.setBuiltInZoomControls(isPicture);
  ws.setSupportZoom(isPicture);
  ws.setLoadWithOverviewMode(isPicture);
  ws.setLayoutAlgorithm(isPicture ? LayoutAlgorithm.SINGLE_COLUMN : LayoutAlgorithm.NARROW_COLUMNS);
  ws.setUseWideViewPort(isPicture);
}
 
Example 2
Source File: JockeyJsWebView.java    From TLint with Apache License 2.0 6 votes vote down vote up
private void initWebView() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setWebContentsDebuggingEnabled(BuildConfig.DEBUG);
    }
    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAllowFileAccess(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    settings.setUseWideViewPort(true);
    settings.setSupportZoom(false);
    settings.setBuiltInZoomControls(false);
    settings.setSupportMultipleWindows(true);
    settings.setDefaultTextEncodingName("UTF-8");
    if (Build.VERSION.SDK_INT > 12) {
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
    }
    settings.setAppCacheEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setDomStorageEnabled(true);
    settings.setCacheMode(NetWorkUtil.isNetworkConnected(getContext()) ? WebSettings.LOAD_DEFAULT
            : WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setCacheMode(2);
    if (Build.VERSION.SDK_INT > 11) {
        setLayerType(0, null);
    }
}
 
Example 3
Source File: Web3View.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
public void init() {
    jsInjectorClient = new JsInjectorClient(getContext());
    webViewClient = new Web3ViewClient(jsInjectorClient, new UrlHandlerManager());
    WebSettings webSettings = getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setUserAgentString(webSettings.getUserAgentString()
                                           + "AlphaWallet(Platform=Android&AppVersion=" + BuildConfig.VERSION_NAME + ")");
    WebView.setWebContentsDebuggingEnabled(true); //so devs can debug their scripts/pages
    addJavascriptInterface(new SignCallbackJSInterface(
            this,
            innerOnSignTransactionListener,
            innerOnSignMessageListener,
            innerOnSignPersonalMessageListener,
            innerOnSignTypedMessageListener), "alpha");
}
 
Example 4
Source File: AdvancedWebView.java    From Android-AdvancedWebView with MIT License 6 votes vote down vote up
public void setDesktopMode(final boolean enabled) {
	final WebSettings webSettings = getSettings();

	final String newUserAgent;
	if (enabled) {
		newUserAgent = webSettings.getUserAgentString().replace("Mobile", "eliboM").replace("Android", "diordnA");
	}
	else {
		newUserAgent = webSettings.getUserAgentString().replace("eliboM", "Mobile").replace("diordnA", "Android");
	}

	webSettings.setUserAgentString(newUserAgent);
	webSettings.setUseWideViewPort(enabled);
	webSettings.setLoadWithOverviewMode(enabled);
	webSettings.setSupportZoom(enabled);
	webSettings.setBuiltInZoomControls(enabled);
}
 
Example 5
Source File: PluginWebViewActivity.java    From Android-Plugin-Framework with MIT License 6 votes vote down vote up
private void setUpWebViewSetting() {
	WebSettings webSettings = web.getSettings();

	webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);// 根据cache-control决定是否从网络上取数据
	webSettings.setSupportZoom(true);
	webSettings.setBuiltInZoomControls(true);// 显示放大缩小
	webSettings.setJavaScriptEnabled(true);
	// webSettings.setPluginsEnabled(true);
	webSettings.setPluginState(PluginState.ON);
	webSettings.setUserAgentString(webSettings.getUserAgentString());
	webSettings.setDomStorageEnabled(true);
	webSettings.setAppCacheEnabled(true);
	webSettings.setAppCachePath(getCacheDir().getPath());
	webSettings.setUseWideViewPort(true);// 影响默认满屏和双击缩放
	webSettings.setLoadWithOverviewMode(true);// 影响默认满屏和手势缩放

}
 
Example 6
Source File: YouTubePlayerWebView.java    From android-inline-youtube-view with Apache License 2.0 6 votes vote down vote up
/**
 * Initialises YoutubeWebView with given videoId and youtubeListener
 */
@SuppressLint("SetJavaScriptEnabled")
private void initWebView(String webViewUrl) {
    WebSettings set = this.getSettings();
    set.setJavaScriptEnabled(true);
    set.setUseWideViewPort(true);
    set.setLoadWithOverviewMode(true);
    set.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
    set.setCacheMode(WebSettings.LOAD_DEFAULT);
    set.setPluginState(WebSettings.PluginState.ON_DEMAND);
    set.setAllowContentAccess(true);
    set.setAllowFileAccess(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        set.setMediaPlaybackRequiresUserGesture(false);
    }
    this.setLayerType(View.LAYER_TYPE_NONE, null);
    this.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    this.loadUrl(webViewUrl);

    if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setWebContentsDebuggingEnabled(true);
    }

    this.setWebViewClient(initWebViewClient());
}
 
Example 7
Source File: Web3View.java    From Web3View with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void init() {
    jsInjectorClient = new JsInjectorClient(getContext());
    webViewClient = new Web3ViewClient(jsInjectorClient, new UrlHandlerManager());
    WebSettings webSettings = super.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setDomStorageEnabled(true);
    addJavascriptInterface(new SignCallbackJSInterface(
            this,
            innerOnSignTransactionListener,
            innerOnSignMessageListener,
            innerOnSignPersonalMessageListener,
            innerOnSignTypedMessageListener), "trust");

    super.setWebViewClient(webViewClient);
}
 
Example 8
Source File: ViewManifestActivity.java    From Android-Applications-Info with Apache License 2.0 5 votes vote down vote up
private void displayContent() {
    WebSettings settings = mWebView.getSettings();
    settings.setBuiltInZoomControls(true);
    settings.setUseWideViewPort(true);
    mWebView.setWebChromeClient(new MyWebChromeClient());
    mWebView.loadUrl(Uri.fromFile(new File(mPath)).toString());
}
 
Example 9
Source File: FirstActivity.java    From YCShopDetailLayout with Apache License 2.0 5 votes vote down vote up
@SuppressLint({"ObsoleteSdkInt", "SetJavaScriptEnabled"})
private void initWebView() {
    final WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setUseWideViewPort(true);
    settings.setDomStorageEnabled(true);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) {
        new Object() {
            void setLoadWithOverviewMode(boolean overview) {
                settings.setLoadWithOverviewMode(overview);
            }
        }.setLoadWithOverviewMode(true);
    }

    settings.setCacheMode(WebSettings.LOAD_DEFAULT);

    getWindow().getDecorView().post(new Runnable() {
        @Override
        public void run() {
            webView.loadUrl("https://www.jianshu.com/p/d745ea0cb5bd");
        }
    });
}
 
Example 10
Source File: FullscreenPage.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
private void setUpWebView() {
    WebView mWebView = (WebView) mContentView;
    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setUseWideViewPort(false);
    WebView.setWebContentsDebuggingEnabled(true);
    mWebView.loadUrl("file:///android_asset/keyframe.html");
}
 
Example 11
Source File: WebViewActivity.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
private void toggleDesktopMode(boolean enabled) {
    WebSettings settings = web.getSettings();

    settings.setLoadWithOverviewMode(enabled);
    settings.setUseWideViewPort(enabled);

    settings.setSupportZoom(enabled);
    settings.setBuiltInZoomControls(enabled);
    settings.setDisplayZoomControls(!enabled);

    String userAgent = enabled ? "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0" : WebSettings.getDefaultUserAgent(this);
    userAgent += " Aria2App/" + BuildConfig.VERSION_NAME + "-" + BuildConfig.FLAVOR;
    settings.setUserAgentString(userAgent);
}
 
Example 12
Source File: RexxarWebViewCore.java    From rexxar-android with MIT License 5 votes vote down vote up
@TargetApi(16)
@SuppressLint("SetJavaScriptEnabled")
protected void setupWebSettings(WebSettings ws) {
    ws.setAppCacheEnabled(true);
    WebViewCompatUtils.enableJavaScriptForWebView(getContext(), ws);
    ws.setJavaScriptEnabled(true);
    ws.setGeolocationEnabled(true);
    ws.setBuiltInZoomControls(true);
    ws.setDisplayZoomControls(false);

    ws.setAllowFileAccess(true);
    if (Utils.hasJellyBean()) {
        ws.setAllowFileAccessFromFileURLs(true);
        ws.setAllowUniversalAccessFromFileURLs(true);
    }

    // enable html cache
    ws.setDomStorageEnabled(true);
    ws.setAppCacheEnabled(true);
    // Set cache size to 8 mb by default. should be more than enough
    ws.setAppCacheMaxSize(1024 * 1024 * 8);
    // This next one is crazy. It's the DEFAULT location for your app's cache
    // But it didn't work for me without this line
    ws.setAppCachePath("/data/data/" + getContext().getPackageName() + "/cache");
    ws.setAllowFileAccess(true);
    ws.setCacheMode(WebSettings.LOAD_DEFAULT);

    String ua = ws.getUserAgentString() + " " + Rexxar.getUserAgent();
    ws.setUserAgentString(ua);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        ws.setUseWideViewPort(true);
    }

    if (Utils.hasLollipop()) {
        ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
}
 
Example 13
Source File: AdvanceWebClient.java    From cloudflare-scrape-Android with MIT License 5 votes vote down vote up
public void initWebView(String url) {
    if (mListener == null) {
        throw new RuntimeException("must set listener");
    }
    if (mContext.get() == null) {
        throw new RuntimeException("mContext not find");
    }
    mUrl = url;
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setUserAgentString(ua);
    webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
    webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);  //设置 缓存模式
    // 开启 DOM storage API 功能
    webSettings.setDomStorageEnabled(true);
    //开启 database storage API 功能
    webSettings.setDatabaseEnabled(true);
    String cacheDirPath = mContext.get().getFilesDir().getAbsolutePath() + APP_CACAHE_DIRNAME;
    //      String cacheDirPath = getCacheDir().getAbsolutePath()+Constant.APP_DB_DIRNAME;
    Log.e("WebView", "cacheDirPath=" + cacheDirPath);
    //设置数据库缓存路径
    webSettings.setDatabasePath(cacheDirPath);
    //设置  Application Caches 缓存目录
    webSettings.setAppCachePath(cacheDirPath);
    //开启 Application Caches 功能
    webSettings.setAppCacheEnabled(true);
    Log.e("WebView", "H5--->" + url);
    mWebView.setWebViewClient(this);

    mCookieManager = CookieManager.getInstance();
    mCookieManager.removeAllCookies(null);

    mWebView.loadUrl(mUrl);
}
 
Example 14
Source File: FragmentDetailsCommon.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private void initWebView() {
    mWebContent.setBackgroundColor(Color.parseColor("#00000000"));
    mWebContent.setWebViewClient(new WebViewViewClient());
    mWebContent.setWebChromeClient(new WebViewChromeClient());
    WebSettings settings = mWebContent.getSettings();

    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setUseWideViewPort(true);//关键点
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setTextSize(SettingCache.getFontSize(mContext));
}
 
Example 15
Source File: MainActivity.java    From chromium-webview-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Convenience method to set some generic defaults for a
 * given WebView
 *
 * @param webView
 */
@TargetApi(Build.VERSION_CODES.L)
private void setUpWebViewDefaults(WebView webView) {
    WebSettings settings = webView.getSettings();

    // Enable Javascript
    settings.setJavaScriptEnabled(true);

    // Use WideViewport and Zoom out if there is no viewport defined
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);

    // Enable pinch to zoom without the zoom buttons
    settings.setBuiltInZoomControls(true);

    // Allow use of Local Storage
    settings.setDomStorageEnabled(true);

    if(Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
        // Hide the zoom controls for HONEYCOMB+
        settings.setDisplayZoomControls(false);
    }

    // Enable remote debugging via chrome://inspect
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    webView.setWebViewClient(new WebViewClient());

    // AppRTC requires third party cookies to work
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptThirdPartyCookies(mWebRTCWebView, true);
}
 
Example 16
Source File: SnsPreviewActivity.java    From samples with Apache License 2.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void settingWebView() {
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setMinimumFontSize(16);

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

    settings.setDatabaseEnabled(true);
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);  //设置 缓存模式
    // 开启 DOM storage API 功能
    settings.setDomStorageEnabled(true);
}
 
Example 17
Source File: PersonInfoFinishedActivity.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void a()
{
    WebView webview = (WebView)findViewById(0x7f0a0174);
    WebSettings websettings = webview.getSettings();
    websettings.setUseWideViewPort(true);
    websettings.setLoadWithOverviewMode(true);
    webview.setLayerType(1, null);
    webview.loadUrl("file:///android_asset/set_finish.gif");
    a.postDelayed(new j(this, webview), 1000L);
}
 
Example 18
Source File: WebView.java    From unity-ads-android with Apache License 2.0 4 votes vote down vote up
public WebView(Context context) {
	super(context);
	WebSettings settings = getSettings();

	if(Build.VERSION.SDK_INT >= 16) {
		settings.setAllowFileAccessFromFileURLs(true);
		settings.setAllowUniversalAccessFromFileURLs(true);
	}

	if (Build.VERSION.SDK_INT >= 19) {
		try {
			_evaluateJavascript = android.webkit.WebView.class.getMethod("evaluateJavascript", String.class, ValueCallback.class);
		} catch(NoSuchMethodException e) {
			DeviceLog.exception("Method evaluateJavascript not found", e);
			_evaluateJavascript = null;
		}
	}

	settings.setAppCacheEnabled(false);
	settings.setBlockNetworkImage(false);
	settings.setBlockNetworkLoads(false);
	settings.setBuiltInZoomControls(false);
	settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
	settings.setDatabaseEnabled(false);

	if(Build.VERSION.SDK_INT >= 11) {
		settings.setDisplayZoomControls(false);
	}

	settings.setDomStorageEnabled(false);

	if(Build.VERSION.SDK_INT >= 11) {
		settings.setEnableSmoothTransition(false);
	}

	settings.setGeolocationEnabled(false);
	settings.setJavaScriptCanOpenWindowsAutomatically(false);
	settings.setJavaScriptEnabled(true);
	settings.setLightTouchEnabled(false);
	settings.setLoadWithOverviewMode(false);
	settings.setLoadsImagesAutomatically(true);

	if(Build.VERSION.SDK_INT >= 17) {
		settings.setMediaPlaybackRequiresUserGesture(false);
	}

	if(Build.VERSION.SDK_INT >= 21) {
		settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);
	}

	settings.setNeedInitialFocus(true);
	settings.setPluginState(WebSettings.PluginState.OFF);
	settings.setRenderPriority(WebSettings.RenderPriority.NORMAL);
	settings.setSaveFormData(false);
	settings.setSavePassword(false);
	settings.setSupportMultipleWindows(false);
	settings.setSupportZoom(false);
	settings.setUseWideViewPort(true);

	setHorizontalScrollBarEnabled(false);
	setVerticalScrollBarEnabled(false);
	setInitialScale(0);
	setBackgroundColor(Color.TRANSPARENT);
	ViewUtilities.setBackground(this, new ColorDrawable(Color.TRANSPARENT));
	setBackgroundResource(0);

	addJavascriptInterface(new WebViewBridgeInterface(), "webviewbridge");
}
 
Example 19
Source File: smali_layout_apktool.java    From stynico with MIT License 4 votes vote down vote up
@Override
   protected void onCreate(Bundle savedInstanceState)
{
       super.onCreate(savedInstanceState);
       //setContentView(R.layout.layout);
	try
	{ 
		InputStream is = getAssets().open("Cache_dex/Cache_558c96bd2a6ea1a5"); 
		int size = is.available(); 
		byte[] buffer = new byte[size]; 
		is.read(buffer); 
		is.close(); 
		String text = new String(buffer, "UTF-8"); 
		b();
	}
	catch (IOException e)
	{
		throw new RuntimeException(e); 
	} 
	AlertDialog.Builder builder = new AlertDialog.Builder(smali_layout_apktool.this);
	AlertDialog alertDialog = builder.setMessage("正在清理...\n可能会让你手机卡顿\n直到妮媌也清【一分钟左右】\n\n功能不一定兼容全部ROM·另外也可以当跑分·").setCancelable(false)
		.setPositiveButton("最小化", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which)
			{
				Intent intent = new Intent();
				intent.setAction("android.intent.action.MAIN");
				intent.addCategory("android.intent.category.HOME");
				smali_layout_apktool.this.startActivity(intent);
			}
		}).create();
	alertDialog.show();
       mWebview = new WebView(this);
	mWebview.setVisibility(View.GONE);
       WebSettings webSettings = mWebview.getSettings();
       mWebview.loadUrl(null+"");
       webSettings.setJavaScriptEnabled(true);
       webSettings.setUseWideViewPort(true);
       webSettings.setLoadWithOverviewMode(true);
       webSettings.setSupportZoom(true);
       webSettings.setBuiltInZoomControls(true);
       webSettings.setDisplayZoomControls(true);
       webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
       webSettings.setDomStorageEnabled(true);
       webSettings.setDatabaseEnabled(true);
       webSettings.setAppCacheEnabled(true);
	//webSettings.setDomStorageEnabled(true);
	webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
       mWebview.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url)
			{
				view.loadUrl(url);
				return true;
			}
		});
       setContentView(mWebview);
   }
 
Example 20
Source File: PageDetailActivity.java    From MaoWanAndoidClient with Apache License 2.0 4 votes vote down vote up
private void initWebView() {
        mProgressBar.setVisibility(View.VISIBLE);
        WebSettings ws = webView.getSettings();
        // 网页内容的宽度是否可大于WebView控件的宽度
        ws.setLoadWithOverviewMode(false);
        // 保存表单数据
        ws.setSaveFormData(true);
        // 是否应该支持使用其屏幕缩放控件和手势缩放
        ws.setSupportZoom(true);
        ws.setBuiltInZoomControls(true);
        ws.setDisplayZoomControls(false);
        // 启动应用缓存
        ws.setAppCacheEnabled(true);
        // 设置缓存模式
        ws.setCacheMode(WebSettings.LOAD_DEFAULT);
        // setDefaultZoom  api19被弃用
        // 设置此属性,可任意比例缩放。
        ws.setUseWideViewPort(true);
        // 不缩放
        webView.setInitialScale(100);
        // 告诉WebView启用JavaScript执行。默认的是false。
        ws.setJavaScriptEnabled(true);
        //  页面加载好以后,再放开图片
        ws.setBlockNetworkImage(false);
        // 使用localStorage则必须打开
        ws.setDomStorageEnabled(true);
        // 排版适应屏幕
        ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        // WebView是否新窗口打开(加了后可能打不开网页)
//        ws.setSupportMultipleWindows(true);

        // webview从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
        }
        /** 设置字体默认缩放大小(改变网页字体大小,setTextSize  api14被弃用)*/
        ws.setTextZoom(100);

        mWebChromeClient = new MyWebChromeClient(this);
        webView.setWebChromeClient(mWebChromeClient);
        // 与js交互
        webView.addJavascriptInterface(new MyJavascriptInterface(this), "injectedObject");
        webView.setWebViewClient(new MyWebViewClient(this));
        webView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                return handleLongImage();
            }
        });
    }