您的位置:首页 > 移动开发

Android 同时加载多个webview 加载很慢解决方式

2016-05-13 11:47 609 查看
    现在做的是平板的项目,需要在主界面同时显示webview,服务器有数据来,需要同时更新加载图形的数据,在低配置的手机上运行会使界面卡住,

在三星平板或者手机上运行还算流畅,经过排除,确定是因为webview的加载过慢导致界面卡顿,所以需要优化webview的加载速度,谷歌了一下,找到以下方法:

1.翻译一下英文大概的意思就是:设置渲染等级为高等、设置为硬件加速、不要有缓存数据

It depends on the web application being loaded. Try some of the approaches below:

Set higher render priority (deprecated from API 18+):

        webview.getSettings().setRenderPriority(RenderPriority.HIGH);

Enable/disable hardware acceleration:
four_chart_webview.getSettings().setRenderPriority(RenderPriority.HIGH);
four_chart_webview.getSettings()
.setCacheMode(WebSettings.LOAD_NO_CACHE);
if (Build.VERSION.SDK_INT >= 11) {
four_chart_webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

} else {
four_chart_webview.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}

2.还有一种是在主配置文件manifest中设置整个应用程序启动硬件加速,大概翻译的意思就是这样:

Adding this?android:hardwareAccelerated="true"?in the manifest was the only thing that significantly improved the performance for me

上述的硬件加速true和false我在手机上没有什么感觉

以下是问答的全文:http://stackoverflow.com/questions/7422427/android-webview-slow
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android 优化 webview