1
,当我通过Slidenerd观看此YouTube视频:动画效果recyclerview滚动
https://www.youtube.com/watch?v=e8ifO1m9g_Q
他建议,如果你想在recyclerview运用动画,使用recyclerview你onBindViewHolder代码中下面的代码:
ObjectAnimator objectAnimatorTranslateY;
if (position > previousPosition) { //this should only activate animation when scrolling up
objectAnimatorTranslateY = ObjectAnimator.ofFloat(holder.itemView, "translationY", 200, 0);
objectAnimatorTranslateY.setDuration(300);
objectAnimatorTranslateY.start();
}
previousPosition = position;
我具有实例化previousPosition作为成员变量为0。
代码ANI配合recyclerview中的项目,以便在滚动时显示为从屏幕底部飞入。
该代码正在工作,但我未能实现的是如何防止代码在列表第一次出现在屏幕上时运行。
我不希望列表项在第一次打开应用程序时被动画化,但只有当它滚动时。回收站视图第一次出现在屏幕上时,如何阻止动画制作者启动?