package com.example.animationdemo;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.ScaleAnimation;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends Activity {
//动画用两种:frame动画/tween动画

ImageView imageView;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

imageView=(ImageView) this.findViewById(R.id.iv);

button=(Button) this.findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
imageView.setBackgroundResource(R.anim.anim_list);
AnimationDrawable ad=(AnimationDrawable) imageView.getBackground();
ad.start();
}
});
// imageView.setImageResource(R.drawable.a);


//透明度
// Animation alphaanim=AnimationUtils.loadAnimation(this, R.anim.alpha);
// imageView.startAnimation(alphaanim);

//旋转
// Animation rotateanim=AnimationUtils.loadAnimation(this, R.anim.rotate);
// imageView.setAnimation(rotateanim);
// rotateanim.start();

//位置变换
// Animation translateanim=AnimationUtils.loadAnimation(this, R.anim.translate);
// imageView.startAnimation(translateanim);

//大小变化
// Animation scaleanim=AnimationUtils.loadAnimation(this, R.anim.scale);
// imageView.startAnimation(scaleanim);

//如果几种效果放到一起,使用AnimationSet
// AnimationSet animationSet=new AnimationSet(true);
// animationSet.addAnimation(translateanim);
// animationSet.addAnimation(scaleanim);
// imageView.startAnimation(animationSet);

// AlphaAnimation alphaAnimation=new AlphaAnimation(0, 1);
// alphaAnimation.setDuration(3000);
// imageView.startAnimation(alphaAnimation);

// ScaleAnimation animation=new ScaleAnimation(0f, 1.4f, 0f, 1.5f, 0.5f, 0.5f);
// animation.setDuration(3000);
// imageView.startAnimation(animation);




}

}