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
在三星平板或者手机上运行还算流畅,经过排除,确定是因为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
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories