Issues to note when adding animations to Recycleview item

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.