本帖最后由 liu 于 2018-12-28 16:20 编辑
组合动画
之前说了位移动画、旋转动画、缩放动画和透明度动画,只不过都是单一的一种动画效果,这次来说下怎么将他们组合起来一起使用
java代码
[Java] 纯文本查看 复制代码 AlphaAnimation alphaAnimation = new AlphaAnimation(0.1f, 1.0f);
alphaAnimation.setRepeatCount(-1);
alphaAnimation.setDuration(3000);
alphaAnimation.setRepeatMode(TranslateAnimation.RESTART);
Animation rotateAnimation = new RotateAnimation(0, 359);
rotateAnimation.setDuration(3000);
rotateAnimation.setRepeatCount(-1);
Animation scaleAnimation = new ScaleAnimation(0, 1.0f, 0f, 1.0f);
scaleAnimation.setDuration(3000);
scaleAnimation.setRepeatCount(-1);
scaleAnimation.setFillAfter(true);
AnimationSet set = new AnimationSet(false);
set.addAnimation(alphaAnimation);
set.addAnimation(rotateAnimation);
set.addAnimation(scaleAnimation);
view.startAnimation(set);
效果图:
大家可以自由组合这几种动画来试试效果
|