简体   繁体   中英

android webview scrolling not smooth, lags

I am working on a simple Android app that has only one activity, a WebView. It works very well on my phone (Android Version 7.1.2 Nougat), but I have received complaints from many users that the scrolling is not smooth and lags a bit (except on Google Pixel).

I've read many answers for this issue and implemented every one of them but it still lags. I've added the following lines of code:

On Android Manifest file:

android:hardwareAccelerated="true"

On MainActivity.java file:

webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
    webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

Is there anything I've missed?

maybe it can help you

getWindow().setFlags(
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM