今天做一个动画,发现设置的时间偶尔失效,概率还挺高.
类似微信聊天页面,点击图片预览,再次点击,动画形式回到聊天页面的效果
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);
网友评论