本篇接上篇:android 动画 – tween动画
上篇讲到创建xxAnimation对象,然后:
- 设置Animation对象相应的数据
设置动画执行事件(单位:毫秒):
setDuration(long durationMills);
如果fillAfter的值为true,则动画执行后,控件将停留在执行结果的状态:
setFillAfter(boolean fillAfter);
如果fillBefore的值为true,则动画执行后,控件将回到动画执行之前的状态:
setFillBefore(boolen fillBefore);
设置动画执行之前的等待时间:
setStartOffSet(long startOffSet);
设置动画再重复执行的次数 注意repeatcount(x)共执行x+1次:
setRepeatCount(int repeatCount);(如果在Animation或者Animationset设置不会起作用,只能在xxAnimation中设置)
设置动作重复的模式 repeatMode为Animation.REVERSE或Animation.RESTART:
l setRepeatMode(int repeatMode);
相应的数据模式设定好以后就要:
- 使用addAnimation方法将Animation对象添加到AnimationSet对象当中
View.setAnimation(animationset);
这样。一个基本的动画就可以展示出来了。
再说一下取消动作:
animation.cancel(); //动作本身取消
animationset.cancel(); //动作集取消
(View控件)img.clearAnimation(); //控件取消附在其上的动作