播放时如何改变动画速度?
How to change animation speed when is playing?
我有 Animation
,我需要在 运行 中更改持续时间或速度。
如何做到这一点?
Animation fadeIn = new AlphaAnimation(1, 0);
fadeIn.setInterpolator(new AccelerateInterpolator()); //add this
fadeIn.setDuration(800);
fadeIn.setFillEnabled(true);
fadeIn.setFillAfter(true);
bt1.startAnimation(fadeIn);
您可以使用 Interpolators to have a variable speed during animation. Example can be found here.
我想你需要两个不同速度的动画。第一个完成后,第二个开始播放。
Animation anim1 = new AlphaAnimation (1, 0.5F);
anim1.setDuration (600); //The slow part.
//set other things for anim1
Animation anim2 = new AlphaAnimation (0.5F, 0);
anim2.setDuration (200); //The fast part.
//set other things for anim2
我有 Animation
,我需要在 运行 中更改持续时间或速度。
如何做到这一点?
Animation fadeIn = new AlphaAnimation(1, 0);
fadeIn.setInterpolator(new AccelerateInterpolator()); //add this
fadeIn.setDuration(800);
fadeIn.setFillEnabled(true);
fadeIn.setFillAfter(true);
bt1.startAnimation(fadeIn);
您可以使用 Interpolators to have a variable speed during animation. Example can be found here.
我想你需要两个不同速度的动画。第一个完成后,第二个开始播放。
Animation anim1 = new AlphaAnimation (1, 0.5F);
anim1.setDuration (600); //The slow part.
//set other things for anim1
Animation anim2 = new AlphaAnimation (0.5F, 0);
anim2.setDuration (200); //The fast part.
//set other things for anim2