简体   繁体   English

不可见的ViewHolder动画在RecyclerView中被延迟

[英]Non-visible ViewHolder animation is delayed in RecyclerView

In the ViewHolder of my RecyclerView, I have a method that is called to animate the alpha value of one of its TextViews. 在我的RecyclerView的ViewHolder中,我有一个被调用来为其TextViews之一的alpha值设置动画的方法。 The ViewHolders are registered to a global notifier in onBindViewHolder and unregistered in onViewRecycled . 该ViewHolders注册到在全球通知onBindViewHolder和未注册的onViewRecycled When notified, all visible ViewHolders run the animation immediately. 收到通知后,所有可见的ViewHolders都会立即运行动画。 Those that are binded to but not currently visible end up delaying the animation until it's visible. 绑定但当前不可见的那些对象最终将动画延迟到可见为止。 My expectation would be that the animation for these ViewHolders would have either already started, or would be skipped entirely. 我的期望是这些ViewHolders的动画要么已经开始,要么将被完全跳过。

I've also created a Gist for the class used in the example. 我还为示例中使用的类创建了一个Gist。

My fix is to only run the animation for ViewHolders that are visible. 我的解决方法是仅对可见的ViewHolders运行动画。 I'm asking this question mostly for enlightenment and also to make sure I'm not missing something here. 我问这个问题主要是为了启蒙,同时还要确保我在这里没有遗漏任何东西。

在此处输入图片说明

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

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