美文网首页android疑难问题
ScaleAnimation .setDuration(1000

ScaleAnimation .setDuration(1000

作者: NullPoint3Exce | 来源:发表于2018-05-11 15:06 被阅读0次

今天做一个动画,发现设置的时间偶尔失效,概率还挺高.
类似微信聊天页面,点击图片预览,再次点击,动画形式回到聊天页面的效果

      final ScaleAnimation animation = new ScaleAnimation(1, 0,1, 0, Animation.RELATIVE_TO_PARENT, 0.5f, Animation.RELATIVE_TO_PARENT, 0.5f);
        animation.setDuration(1000);
        animation.setFillAfter(false);
        animation.setInterpolator(new AccelerateDecelerateInterpolator());
        mScalableImageView.clearAnimation();
        mScalableImageView.startAnimation(animation);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                isAnimFinished = false;

                startTime = System.currentTimeMillis();
                Log.e("chents","onAnimationStart=");
                mViewPager.setAlpha(0f);
                mBackgroundView.setAlpha(0f);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                isAnimFinished = true;
                Log.e("chents","onAnimationEnd=time="+(System.currentTimeMillis()-startTime));
                contentContainer.removeView(PreviewLayout.this);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                Log.e("chents","onAnimationRepeat=");
            }
        });

最后解决:

//使用当前view执行动画
 startAnimation(animation);

相关文章

网友评论

    本文标题:ScaleAnimation .setDuration(1000

    本文链接:https://www.haomeiwen.com/subject/puabhftx.html