【问题标题】:Animation Listener for Custom Animation自定义动画的动画监听器
【发布时间】:2012-08-17 07:44:04
【问题描述】:

我已经使用 fragmentTansaction.setCustomAnimation(in,out) 为片段事务设置了自定义动画。我想知道动画的开始和结束并触发一些相应的动作。我怎样才能做到这一点?是否可以设置一些监听器?

【问题讨论】:

标签: android animation android-animation fragment


【解决方案1】:

您可以在 onStart() 中为 getDecorView() 使用动画

   @Override
    public void onStart() {
        super.onStart();

        if (getDialog().getWindow().getDecorView()) {
            ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(getDialog().getWindow().getDecorView(),
                    PropertyValuesHolder.ofFloat(View.Y, 0, 1000));
            objectAnimator.setDuration(1000);
            objectAnimator.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {

                }

                @Override
                public void onAnimationEnd(Animator animation) {

                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            });
            objectAnimator.start();
        }

    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    • 2019-11-27
    • 1970-01-01
    相关资源
    最近更新 更多