属性动画不回调onAnimationStart

使用属性动画简单使用示例如下
ObjectAnimator animatorSX = ObjectAnimator.ofFloat(mTakePhoto,View.SCALE_X,1.0f,0.625f);
ObjectAnimator animatorSY = ObjectAnimator.ofFloat(mTakePhoto,View.SCALE_Y,1.0f,0.625f);
ObjectAnimator animatorTY = ObjectAnimator.ofFloat(mTakePhoto,View.TRANSLATION_Y,0,getResources().getDimensionPixelOffset(R.dimen.x50));
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(250);
animatorSet.setStartDelay(50);
animatorSet.playTogether(animatorSX,animatorSY,animatorTY);
animatorSet.addListener(new AnimatorListenerAdapter() {

    @Override
    public void onAnimationStart(Animator animation, boolean isReverse) {
        mTvImport.setVisibility(visible);
        mEffectView.setVisibility(visible);
        mTvEffect.setVisibility(visible);
        mBeautyView.setVisibility(visible);
        if(animatorListenerAdapter != null){
            animatorListenerAdapter.onAnimationStart(animation);
        }
    }

    @Override
    public void onAnimationEnd(Animator animation) {
        mTakePhoto.setVisibility(visible);
        if(animatorListenerAdapter != null){
            animatorListenerAdapter.onAnimationEnd(animation);
        }
    }
});
animatorSet.start();

粗略一看没有任何问题,而且在大部分手机上也是正常的的,但是有一天一个测试拿着Redmi 3S跑过来说这个地方没有动画而且控件也没有隐藏好大的bug,没多想我觉得应该没问题啊,怎么会出现这种情况大部分手机都是好的这个手机怎么回事,后来经过调试发现原来是回调方法重写错了

AnimatorListenerAdapter有很多回调方法而且他也有start和end的回调,但是他同时实现了Animator.AnimatorListener接口这个接口也雨两个回调方法

问题就出在这两个方法的重写上,这里我们重新AnimatorListenerAdapter本身的OnAnimationStart(Animator animation)就可以了


                    @Override
                    public void onAnimationStart(Animator animation, boolean isReverse) {
                        //没有回调
                    }

                    @Override
                    public void onAnimationStart(Animator animation) {
                        //有回调
                        mTvImport.setVisibility(visible);
                        mEffectView.setVisibility(visible);
                        mTvEffect.setVisibility(visible);
                        mBeautyView.setVisibility(visible);
                        if(animatorListenerAdapter != null){
                            animatorListenerAdapter.onAnimationStart(animation);
                        }
                    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值