这是我的场景。
首先,我在我的视图(View.startAnimation(animationSet))中设置了一个动画,其中animationSet同时由平移+旋转+缩放组成。它工作得很好。在那个animationSet上,我有fillAfter(true)。经过一段时间用户点击一个按钮和onClick,我必须启动新的ScaleAnimation在同一视图。因此,如果我这样做:
@Override
public void onClick(View v) {
ScaleAnimation scaleAnimation = new ScaleAnimation(mOldScaleFactor, mScaleFactor, mOldScaleFactor, mScaleFactor, mPivotX, mPivotY);
scaleAnimation.setDuration(ANIMATION_DURATION_MILIS);
scaleAnimation.setStartOffset(ANIMATION_OFFSET_MILIS);
scaleAnimation.setFillAfter(true);
v.startAnimation(scaleAnimation);
}所有先前的动画(平移+旋转+缩放)都会被遗忘。
如何从旧动画结束的地方开始新动画?
发布于 2012-03-15 19:24:33
您可以尝试实现一个侦听器,并可能捕获前一个动画停止时的信息,但是我不确定您是否能够查询动画的状态。另一种选择是确保动画停止到已知状态。这样,您就可以知道如何开始下一个动画。
public float param1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
//load text view to add animation
ImageView image1 = (ImageView) findViewById(R.id.splash_imageView1);
Animation fade1 = AnimationUtils.loadAnimation(this, R.anim.fade_anim);
image1.startAnimation(fade1);
fade1.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
//interrogate animation here
}https://stackoverflow.com/questions/5731019
复制相似问题