@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img1 = (ImageView) findViewById(R.id.point1);
img2 = (ImageView) findViewById(R.id.point2);
img3 = (ImageView) findViewById(R.id.point3);
img4 = (ImageView) findViewById(R.id.point4);
img5 = (ImageView) findViewById(R.id.point5);
img6 = (ImageView) findViewById(R.id.point6);
img7 = (ImageView) findViewById(R.id.point7);
mTextView = (TextView) findViewById(R.id.loading);
textView = (TextView) findViewById(R.id.stop);
final ObjectAnimator img1xstart = ObjectAnimator.ofFloat(img1, "scaleX", 1.0f, 1.5f);
final ObjectAnimator img1ystart = ObjectAnimator.ofFloat(img1, "scaleY", 1.0f, 1.5f);
final ObjectAnimator img1xend = ObjectAnimator.ofFloat(img1, "scaleX", 1.5f, 1.0f);
final ObjectAnimator img1yend = ObjectAnimator.ofFloat(img1, "scaleY", 1.5f, 1.0f);
final ObjectAnimator img2xstart = ObjectAnimator.ofFloat(img2, "scaleX", 1.0f, 1.5f);
final ObjectAnimator img2ystart = ObjectAnimator.ofFloat(img2, "scaleY", 1.0f, 1.5f);
final ObjectAnimator img2xend = ObjectAnimator.ofFloat(img2, "scaleX", 1.5f, 1.0f);
final ObjectAnimator img2yend = ObjectAnimator.ofFloat(img2, "scaleY", 1.5f, 1.0f);
final ObjectAnimator img3xstart = ObjectAnimator.ofFloat(img3, "scaleX", 1.0f, 1.5f);
final ObjectAnimator img3ystart = ObjectAnimator.ofFloat(img3, "scaleY", 1.0f, 1.5f);
final ObjectAnimator img3xend = ObjectAnimator.ofFloat(img3, "scaleX", 1.5f, 1.0f);
final ObjectAnimator img3yend = ObjectAnimator.ofFloat(img3, "scaleY", 1.5f, 1.0f);
mTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animSet = new AnimatorSet();
animSet.play(img1xstart).with(img1ystart);
animSet.setDuration(500);
animSet.start();
animSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animSet2 = new AnimatorSet();
animSet2.play(img2xstart).with(img2ystart);
animSet2.play(img1xend).with(img1yend);
animSet2.setDuration(500);
animSet2.start();
animSet2.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animSet3 = new AnimatorSet();
animSet3.play(img3xstart).with(img3ystart);
animSet3.play(img2xend).with(img2yend);
animSet3.setDuration(500);
animSet3.start();
animSet3.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animSet.start();
animSet4 = new AnimatorSet();
animSet4.play(img3xend).with(img3yend);
animSet4.setDuration(500);
animSet4.start();
}
});
}
});
}
});
}
});
textView.setOnClickListener(new View.OnClickListener() {//
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onClick(View v) {
/* animSet.pause();
animSet2.pause();
animSet3.pause();
animSet4.pause();*/
/* animSet.end();
animSet2.end();
animSet3.end();*/
// animSet4.end();
//
img1.clearAnimation();
img2.clearAnimation();
img3.clearAnimation();
/* animSet.cancel();
animSet2.cancel();
animSet3.cancel();
animSet4.cancel();*/
}
});
}
这是自己实验的小圆点循环加载的程序 是很麻烦 也还在学习中。。想请教一下这里我调用什么方法才能吧这个动画循环停止掉啊?求方法。。
自己试了很多都不行