在滚动时使用动画RecyclerView
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="@android:anim/decelerate_interpolator">
<translate
android:duration="700"
android:fromYDelta="100%p"
android:toYDelta="0%p"
/>
</set>
我在回收器适配器中运行:
Animation animation = AnimationUtils.loadAnimation(mainActivity, R.anim.up_from_bottom);
holder.itemView.startAnimation(animation);
动画按预期工作,但如果我向上滚动,结果不是很漂亮,我尝试实现以下内容:
我想这样做,以便在向上滚动时,从上方加载项目,向下滚动时,因为它们是从下方加载的,所以我不能。然后我试着让它向下滚动时有动画,向上滚动时没有动画,我也做不到。如果有人知道,请实际安排两个选项之一。
作为一种选择,使用一个有很多的库。 例如:
或挂起一个滚动监听器 - 一个动画,另一个