简体   繁体   English

Cordova android 滚动/性能问题

[英]Cordova android scrolling/performance issues

I use the following CSS to create smooth scrolling for my Cordova app我使用以下 CSS 为我的 Cordova 应用程序创建平滑滚动

.scrollable { 
    overflow: auto;
    -webkit-transition-property: top, bottom;
    transition-property: top, bottom;
    -webkit-transition-duration: .2s, .2s;
    transition-duration: .2s, .2s;
    -webkit-transition-timing-function: linear, linear;
    transition-timing-function: linear, linear;
    -webkit-overflow-scrolling: touch;
    -webkit-transform: translateZ(0);
    -webkit-backface-visibility: hidden;
}

This works wonderfully on iOS, but for some reason on Android not so much.这在 iOS 上效果很好,但出于某种原因,在 Android 上效果不佳。 Overall performance with Android isn't close to what iOS is either, but it is most noticeable when scrolling. Android 的整体性能也不接近 iOS,但在滚动时最为明显。 Any suggestions?有什么建议? I have android:hardwareAccelerated="true" on, but that doesn't seem to make much of a difference.我打开了android:hardwareAccelerated="true" ,但这似乎没有太大区别。

Android browser scrolling is always a pain, the performance is much worse than iOS. Android浏览器滚动总是很痛苦,性能比iOS差很多。 That's why hybrid app frameworks like Ionic has introduced native scrolling to android , which makes the performance much better. 这就是为什么像Ionic这样的混合应用程序框架已经引入了原生滚动到android ,这使得性能更好。 Ionic really rocks, but if you don't want to use it, you may do some Googling to find out more information about android native scrolling, or read its source code to find out how they achieved it and port it to your project. Ionic真的很震撼,但如果你不想使用它,你可以做一些谷歌搜索以找到有关Android原生滚动的更多信息,或阅读其源代码以了解他们如何实现它并将其移植到您的项目中。

Another way to solve this problem is to embed Crosswalk to your android app, it's a Chromium based webview. 解决这个问题的另一种方法是将Crosswalk嵌入到你的Android应用程序中,这是一个基于Chromium的webview。 The downside is that the size of your APK will increase by 20MB, but performance and consistency on different versions of Android OS will really improve a lot. 缺点是你的APK的大小将增加20MB,但不同版本的Android操作系统的性能和一致性将真正提高很多。

In this article I assume that the reader is a cordova developer, and I'm not going to teach you the basics for that there are millions of articles you can find in web. 在本文中,我假设读者是一名cordova开发人员,我不打算教你基本知识,因为你可以在网上找到数百万篇文章。

So if you are using jQuery, jQuery UI and row java scripts with apache cordova it's still ok if you developing some demo project or a pretty simple app. 因此,如果你正在使用jQuery,jQuery UI和带有apache cordova的行java脚本,如果你开发一些演示项目或一个非常简单的应用程序,它仍然可以。

But for a commercial level project you must use Angular JS or higher angular version ( IONIC Framework - Extended version of cordova ) to get better user experience. 但是对于商业级项目,您必须使用Angular JS或更高角度版本(IONIC Framework - Cordova的扩展版本)来获得更好的用户体验。

I have no offence towards to jQuery and jQuery UI as they are still great tools. 我对jQuery和jQuery UI没有任何冒犯,因为它们仍然是很棒的工具。 But when it's come to hybrid application development Angular perform lot better than jQuery or jQuery UI. 但是当它来到混合应用程序开发时,Angular比jQuery或jQuery UI执行得更好。

https://guntucomputerhacks.blogspot.com.au/2017/11/apache-cordova-scroll-bar-lagging-on.html https://guntucomputerhacks.blogspot.com.au/2017/11/apache-cordova-scroll-bar-lagging-on.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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