package com.example.thinkpad.animation;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
public class Main3Activity extends AppCompatActivity {
ImageView imageView0;
ImageView imageView1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
imageView0=(ImageView)findViewById(R.id.img0);
imageView1=(ImageView)findViewById(R.id.img1);
TranslateAnimation translateAnimation=new TranslateAnimation(Animation.RELATIVE_TO_PARENT,0f,
Animation.RELATIVE_TO_PARENT,0.5f,
Animation.RELATIVE_TO_PARENT,0f,
Animation.RELATIVE_TO_PARENT,-0.5f);
translateAnimation.setDuration(3000);
translateAnimation.setRepeatCount(1);
RotateAnimation rotateAnimation=new RotateAnimation(0,360,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
rotateAnimation.setRepeatCount(Animation.INFINITE);
rotateAnimation.setDuration(3000);
ScaleAnimation scaleAnimation=new ScaleAnimation(1.0f,0.5f,1.0f,0.5f, Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
final AlphaAnimation alphaAnimation=new AlphaAnimation(1.0f,0.0f);
final AnimationSet animationSet=new AnimationSet(false);
scaleAnimation.setDuration(3000);
scaleAnimation.setRepeatCount(1);
alphaAnimation.setRepeatCount(1);
alphaAnimation.setDuration(3000);
animationSet.addAnimation(rotateAnimation);
animationSet.addAnimation(translateAnimation);
animationSet.addAnimation(alphaAnimation);
animationSet.addAnimation(scaleAnimation);
RotateAnimation rotateAnimation1=new RotateAnimation(0,360,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
rotateAnimation1.setRepeatCount(2);
rotateAnimation1.setDuration(3000);
rotateAnimation1.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Log.d("onstart","start");
}
@Override
public void onAnimationEnd(Animation animation) {
imageView1.setAnimation(animationSet);
imageView1.startAnimation(animationSet);
}
@Override
public void onAnimationRepeat(Animation animation) {
Log.d("repeat3","goodgood");
}
});
imageView0.setAnimation(rotateAnimation1);
}
}