public class Ani02 extends Activity {
private ImageView iv;
private Animation an1, an2, an3, an4, an5;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initAnim();
iv = (ImageView)findViewById(R.id.ImageView01);
iv.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN){
iv.startAnimation(an1);
}
return false;
}
});
}
private void initAnim(){
an1 = AnimationUtils.loadAnimation(this, R.anim.trans);
an2 = AnimationUtils.loadAnimation(this, R.anim.rotate);
an3 = AnimationUtils.loadAnimation(this, R.anim.alpha);
an4 = AnimationUtils.loadAnimation(this, R.anim.scale);
an5 = AnimationUtils.loadAnimation(this, R.anim.all);
Animation.AnimationListener listener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if(animation == an1){
iv.startAnimation(an2);
}else if(animation == an2){
iv.startAnimation(an3);
}else if(animation == an3){
iv.startAnimation(an4);
}else if(animation == an4){
iv.startAnimation(an5);
}else{
}
}
};
an1.setAnimationListener(listener);
an2.setAnimationListener(listener);
an3.setAnimationListener(listener);
an4.setAnimationListener(listener);
an5.setAnimationListener(listener);
}
}
'스마트폰 > 안드로이드' 카테고리의 다른 글
데이터 바인딩2 공부 (0) | 2011.05.13 |
---|---|
데이터 바인딩1 공부 (0) | 2011.05.13 |
TabHost 공부. (0) | 2011.05.13 |
Activity Event 공부 (0) | 2011.05.13 |
안드로이드 개발 개요. (0) | 2011.05.02 |