我有一个片段,这里是 onCreateView 方法:
@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).commit();
时删除片段。如果我正确理解Lottie 方法返回 false 时动画已经结束,并且由于在我的配置中动画没有循环,这是我应该删除当前片段的时候。但我不能只使用 if 语句,因为当它执行时,动画可能仍在进行。isAnimating()
我需要一种在 Lottie 动画结束时移除片段的方法,我该怎么做?