iPhone dev: Increase scroll speed in UIWebView?

后端 未结 5 1179
滥情空心
滥情空心 2021-02-09 04:41

I have an app in which I render local HTML files in a UIWebView. The files, however, are sometimes large, and getting to where you want takes a long time with the default scroll

5条回答
  •  忘了有多久
    2021-02-09 05:18

    Old question but these setting or trick really helped me even in 2018.

    Follow these simple coding tricks to improve Android WebView Performance:

    WebView mWebView = new WebView(this);
    WebSettings settings = mWebView.getSettings();
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(false);
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.setScrollbarFadingEnabled(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setDomStorageEnabled(true);
    
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    
        mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    
    } else {
    mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    

提交回复
热议问题