[英]how to optimize renderspeed in android webview
Is there a possibility to enhance the rendering speed in webview? 是否有可能提高webview中的渲染速度? With a simple innerHTML it takes close to 1 sec to display the content although the js rendering takes a few ms.
使用简单的innerHTML,显示内容需要接近1秒,尽管js渲染需要几毫秒。 With IOS, exactly the same code is running swiftly and perfectly, even with less performant hardware.
使用IOS,即使使用性能较低的硬件,完全相同的代码也可以快速而完美地运行。
Tested under Android: 2.3, 3.2, 4.0 (Desire HD, Galaxy Nexus, Galaxy Tab) IOS: 4, 5 (iPhones 3gs, 4) 在Android下测试:2.3,3.2,4.0(Desire HD,Galaxy Nexus,Galaxy Tab)IOS:4,5(iPhone 3gs,4)
Appreciate any helpful responses! 感谢任何有用的回应!
There are a few things you can try: 您可以尝试以下几种方法:
Turn on hardware acceleration by adding android:hardwareAccelerated="true"
to the application or activity tag in the Android manifest file. 通过将
android:hardwareAccelerated="true"
添加到Android清单文件中的应用程序或活动标记来启用硬件加速。 More info here: http://developer.android.com/guide/topics/graphics/hardware-accel.html 更多信息: http : //developer.android.com/guide/topics/graphics/hardware-accel.html
Modify the RenderPriority of the webview - http://developer.android.com/reference/android/webkit/WebSettings.RenderPriority.html 修改webview的RenderPriority - http://developer.android.com/reference/android/webkit/WebSettings.RenderPriority.html
Optimize your javaScript and CSS to minimize the number of reflows, memory used, and DOM size - http://www.html5rocks.com/en/mobile/mobifying.html#toc-optimizations 优化您的javaScript和CSS,以最大限度地减少回流,使用的内存和DOM大小 - http://www.html5rocks.com/en/mobile/mobifying.html#toc-optimizations
Personally, I found that keeping the DOM as small as possible, and enabling hardware acceleration made all of the difference between an unusable app, and a fairly smooth app. 就个人而言,我发现保持DOM尽可能小,并且启用硬件加速使得无法使用的应用程序和相当流畅的应用程序之间存在差异。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.