今天做一個(gè)動(dòng)畫(huà),發(fā)現(xiàn)設(shè)置的時(shí)間偶爾失效夕春,概率還挺高.
類(lèi)似微信聊天頁(yè)面投慈,點(diǎn)擊圖片預(yù)覽,再次點(diǎn)擊妈倔,動(dòng)畫(huà)形式回到聊天頁(yè)面的效果
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=");
}
});
最后解決:
//使用當(dāng)前view執(zhí)行動(dòng)畫(huà)
startAnimation(animation);