优化WebView渲染...寻求替代已弃用的代码

时间:2019-02-03 15:20:53

标签: android webview rendering deprecated hybrid

Code for rendering webview

String url = getIntent().getExtras().getString("url");
    webView = (WebView) findViewById(R.id.webView);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.loadUrl(url);
    webView.setWebViewClient(new WebViewClient());
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);
    webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webView.getSettings().setAppCacheEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    webSettings.setUseWideViewPort(true);
    webSettings.setSavePassword(true);
    webSettings.setSaveFormData(true);
    webSettings.setEnableSmoothTransition(true);
    webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT){
        webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);

    }else{
        webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

我正在尝试在我的android应用中加载Web视图,但是其中一些方法:setRenderPriority,setSmoothTransition,已弃用...寻求替代方法

0 个答案:

没有答案