'How to make two different RecyclerView animations from bottom and top?
I need that when I scroll the RecyclerView each element appears or disappears on the screen, with animation. This option:
android:layoutAnimation="@anim/layout_animation"
Starts animation only on first run Also tried like this
private fun setAnimation(view: View, position: Int) {
if (position > lastPosition) {
val animation: Animation = AnimationUtils.loadAnimation(context, R.anim.slide_up_recycler)
view.startAnimation(animation)
lastPosition = position
if (lastPosition == 1) {
lastPosition = -1
}
} else if (position < lastPosition) {
val animation: Animation = AnimationUtils.loadAnimation(context, R.anim.slide_down_recycler)
view.startAnimation(animation)
lastPosition = position
if (lastPosition == 2) lastPosition = 0
}
}
In onBindViewHolder, there is an animation when scrolling in both directions, but not only when the element appears on the screen, but even when the element is not visible but loaded into the list. In this case, the animation is not visible. I need to make the animation work on scrolling from bottom to top when an element appears (at the bottom of the screen) and animation on the bottom element when scrolling from top to bottom (at the bottom of the screen) before it disappears from the screen. Please tell me how this can be done. It should look like this:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

