Android – change the checkbox checked with the animation in recyclerview

If the user clicks Check@R_ 662_ 2419 @, it will run a very beautiful animation (on lollipop)

But if I call programmatically myCheck@R_ 662_ 2419@.toggle (), it will not run the animation, but immediately display the new state. Can smooth animation run when the check state is changed programmatically?

Edit: originally, when this is a recyclerview item, it does not run animation. Otherwise, it runs

Edit2: the problem is with the project animator. It seems that it will kill all other animations before starting the animation. I guess the exact line of this will cause the problem

resolvent:

I know this question is a year old, but maybe we can reopen the discussion. So far, recyclerview can still kill animation, and because I can't find a simple answer to this question, I'll try it

You can animate within the list using mainthread's handler

Handler mainHandler = new Handler(mContext.getMainLooper());
mainHandler.post(new Runnable() {
    @Override
    public void run() {
        holder.mCheck@R_662_2419@.toggle();
     }
});

This may be a kill correction, but it applies to any type of animation, even inside the onbindviewholder. I strongly recommend checking whether the animation should be played in advance or even scrolling

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>