最近在Android开发当中,用到的动画效果。
public void onClick(View arg0) {
// TODO 自动生成的方法存根
switch (arg0.getId()) {
case R.id.danru://淡入淡出
AnimationSet aset=new AnimationSet(true);
AlphaAnimation aa=new AlphaAnimation(1,0);
aa.setDuration(2000);
aset.addAnimation(aa);
btn_danru.startAnimation(aset);
break;
case R.id.yuanzhuan://旋转效果
AnimationSet aset_2=new AnimationSet(true);
RotateAnimation aa_2=new RotateAnimation(0,360,
Animation.RELATIVE_TO_SELF,0.5f,
Animation.RELATIVE_TO_SELF,0.5f);
aa_2.setDuration(2000);
aset_2.addAnimation(aa_2);
btn_totate.startAnimation(aset_2);
break;
case R.id.suofang://缩放效果
AnimationSet aset_3=new AnimationSet(true);
ScaleAnimation aa_3=new ScaleAnimation(1, 0.1f, 1, 0.1f,Animation.RELATIVE_TO_SELF,1f,Animation.RELATIVE_TO_SELF,1f);
aa_3.setDuration(2000);
aset_3.addAnimation(aa_3);
btn_suofang.startAnimation(aset_3);
break;
case R.id.yidong://移动效果
AnimationSet aset_4=new AnimationSet(true);
TranslateAnimation aa_4=new TranslateAnimation(Animation.RELATIVE_TO_PARENT,0,Animation.RELATIVE_TO_PARENT, 1,
Animation.RELATIVE_TO_PARENT, 0,Animation.RELATIVE_TO_PARENT, 1);
aa_4.setDuration(2000);
aset_4.addAnimation(aa_4);
btn_yidong.startAnimation(aset_4);
break;
}
}
Android 四种简单的动画(淡入淡出、旋转、移动、缩放效果)
原文:http://www.cnblogs.com/hyyweb/p/5133075.html