简体   繁体   English

recyclerView滞后滚动

[英]recyclerView scrolls with lag

I have a recyclerView with match parent items. 我有一个带有匹配父项的recyclerView In recyclerView item, I have 48 relative layouts and a background and it scrolls without any problems. recyclerView项目中,我有48个相对布局和背景,并且滚动时没有任何问题。 Since I added lottie animationView in items, recyclerView scrolls but with lag. 因为我在项目中添加了lottie animationView ,所以recyclerView滚动但有滞后。 I tried to change the cache size, pause animation when it detached from window, compress background image, using another thread, converting images to bitmap but it did not help. 我试图更改缓存大小,从窗口分离时暂停动画,压缩背景图像,使用另一个线程,将图像转换为位图,但这没有帮助。

Should i try to draw views or something like it or is there something else that i can do? 我应该尝试绘制视图或类似内容还是可以做些其他事情?

after one week of searching and testing another ways to play animation i found my solution solution is to use different method to play animation like gif but gif has transparenty and if you have an animation that it has transparent parts, the animation have white border that is very awfull to use, another way to do this is to use apng ,apng is a animated version of png and it resolve the problem of transparenty,but in recyclerView it has problems, like when you scroll recyclerView up or down that animation get out of screen, it will stop and you should set up animation when ever it attached to windows and it decrease the performance, but what is the final solution of this problem? 经过一周的搜索和测试,另一种播放动画的方式后,我发现我的解决方案是使用其他方法播放gif等动画,但是gif具有透明性,如果您的动画具有透明部分,则该动画具有白色边框,即使用起来非常糟糕,另一种方法是使用apng,apng是png的动画版本,它解决了透明性的问题,但是在recyclerView中它有问题,例如当您上下滚动recyclerView时,该动画会消失屏幕,它将停止并且您应该在连接到Windows时设置动画,这会降低性能,但是此问题的最终解决方案是什么? webp. webp。 webp is a format that created by google and you can use it in android with fresco library, and use webp animated images that has not problem of transparenty and it is very high performance, acctually animation size is lower than a lottie animation! webp是由Google创建的一种格式,您可以在带有fresco库的android系统中使用它,并使用webp动画图像,该图像不存在透明性问题,并且性能非常好,动画大小实际上比乐透动画要小! and is very easy to use, i added the library,and easily call it : 并且非常易于使用,我添加了该库,并轻松调用它:

 DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(yourUri)
            .setAutoPlayAnimations(true)
            .build();

and easily set controller to SimpleDraweeView : 并轻松地将控制器设置为SimpleDraweeView:

simpleDraweeView.setController(controller);

it was my solution to my own question, hope it help you. 这是我对自己问题的解决方案,希望对您有所帮助。

Try putting the recyclerview in side a NestedScroll View. 尝试将recyclerview放在NestedScroll View的旁边。 and in recyclerView put nestedscrollingEnabled = false. 并在recyclerView中将nestedscrollingEnabled = false。

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

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