不使用监听机制——动画先后顺序的执行
package com.example.seven;
import android.R.animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
@SuppressLint("NewApi")
public class MainActivity extends Activity {
private ImageView iv_zhangxin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iv_zhangxin = (ImageView) findViewById(R.id.iv_zhangxin);
MyClick mc = new MyClick();
iv_zhangxin.setOnClickListener(mc);
}
private class MyClick implements OnClickListener {
@Override
public void onClick(View v) {
ObjectAnimator scaleXAnimator=ObjectAnimator.ofFloat(iv_zhangxin, "scaleX", 1.0f,2.0f);
ObjectAnimator scaleYAnimator=ObjectAnimator.ofFloat(iv_zhangxin, "scaleY", 1.0f,2.0f);
ObjectAnimator translationAnimator=ObjectAnimator.ofFloat(iv_zhangxin, "translationX", 1.0f,50.f);
AnimatorSet animatorSet=new AnimatorSet();
animatorSet.setDuration(5000);
//缩放动画执行完毕的时候执行平移动画--不使用listenner
animatorSet.play(scaleYAnimator).with(scaleXAnimator)
.before(translationAnimator);
animatorSet.start();
}
}
}
虽然动画的执行有先后同时,但却不使用动画执行的监听