Android 动画标签——set

作用:动画合集

文件目录:res/anim/my_set.xml






Java代码:
AnimationSet set = (AnimationSet ) AnimationUtils.loadAnimation(this,R.anim.my_set);
imageView.startAnimation(set);

纯代码使用:(AnimationSet)
RotateAnimation rotateAnimation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setFillAfter(true);// 设置保持动画最后的状态  
rotateAnimation.setDuration(3000);// 设置动画时间  
rotateAnimation.setRepeatCount(-1);//设置重复次数
imageView.startAnimation(rotateAnimation);

TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 0, 800);
translateAnimation.setRepeatCount(-1);//设置重复次数
imageView.startAnimation(translateAnimation);

AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(rotateAnimation);
animationSet.addAnimation(translateAnimation);
imageView.startAnimation(animationSet);

也可以单个写,方法设置都一样。

你可能感兴趣的:(Android,动画)