After you animate the item, there is no problem when sliding slowly, but a quick swipe will cause a card-screen phenomenon.
Public Abstract class baseanimadapter extends baseadapter { Private intLastposition =-1;@Override Public void Onbindviewholder(Recyclerview.viewholder holder,intPosition) {setanimation (holder.itemview, position); }protected void setanimation(View viewtoanimate,intPosition) {if(Position > Lastposition) {Animation Animation = animationutils.loadanimation (Viewtoanimate.getcontext (), r.anim.item_slide_bottom_up); Viewtoanimate.startanimation (animation); Lastposition = position; } }
The problem is that after the animation is set up, the animation is not cleaned up in time, and the following code is added:
Public Abstract class baseanimadapter extends baseadapter { Private intLastposition =-1;@Override Public void Onbindviewholder(Recyclerview.viewholder holder,intPosition) {setanimation (holder.itemview, position); }protected void setanimation(View viewtoanimate,intPosition) {if(Position > Lastposition) {Animation Animation = animationutils.loadanimation (Viewtoanimate.getcontext (), r.anim.item_slide_bottom_up); Viewtoanimate.startanimation (animation); Lastposition = position; } }@Override Public void Onviewdetachedfromwindow(Recyclerview.viewholder Holder) {Super. Onviewdetachedfromwindow (holder); Holder.itemView.clearAnimation (); }}
Issues to note when adding animations to Recycleview item