如何知道抽奖动画何时完成?

编程入门 行业动态 更新时间:2024-10-11 05:26:24
本文介绍了如何知道抽奖动画何时完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个片段,这是onCreateView方法:

I have a fragment, here is the onCreateView method:

@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment mView = inflater.inflate(R.layout.fragment_added_to_cart_anim, container, false); ButterKnife.bind(this, mView); mAddedToCartAnimation.setAnimation("checked_done_.json"); mAddedToCartAnimation.loop(false); mAddedToCartAnimation.playAnimation(); // Remove fragment when the animation is finished. return mView; }

我需要使用 getActivity().getSupportFragmentManager().beginTransaction().remove(this)mit(); 删除片段,当 lottie 动画已结束.如果在 isAnimating() Lottie方法返回false时我理解正确,则动画已经结束,并且由于在我的配置中动画不循环,这是我应该删除当前片段的时候.但是我不能只使用if语句,因为执行该动画时,动画可能仍会继续运行.

I need to remove the fragment using getActivity().getSupportFragmentManager().beginTransaction().remove(this)mit(); when the lottie animation has ended. If I understand correctly when the isAnimating() Lottie method returns false the animation has ended and since in my configuration the animation does not loop this is when I should remove the current fragment. But I can't just use an if statement since when it is executed the animation may still be going.

我需要一种在乐蒂动画结束时删除片段的方法,该怎么办?

I need a way to remove the fragment when the Lottie animation ends, how do I do this?

推荐答案

此代码对我有用:

mAddedToCartAnimation.addAnimatorListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { Log.e("Animation:","start"); } @Override public void onAnimationEnd(Animator animation) { Log.e("Animation:","end"); //Your code for remove the fragment try { getActivity().getSupportFragmentManager() .beginTransaction().remove(this)mit(); } catch(Exception ex) { ex.toString(); } } @Override public void onAnimationCancel(Animator animation) { Log.e("Animation:","cancel"); } @Override public void onAnimationRepeat(Animator animation) { Log.e("Animation:","repeat"); } });

我希望这可以解决您的问题:)

I hope this solve your problem :)

更多推荐

如何知道抽奖动画何时完成?

本文发布于:2023-11-25 11:02:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629494.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动画

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!