1
如何控制动画的速度?翻译动画从底部到顶部,我想在执行动画的过程中减慢动画速度。我怎样才能做到这一点?以下是我有:有没有办法在执行时减慢翻译动画的速度?
public void SlideToAbove() {
Animation slide = null;
slide = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
slide.setDuration(300);
slide.setFillAfter(true);
slide.setFillEnabled(true);
toolBar.startAnimation(slide);
final Animation finalSlide = slide;
slide.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(
toolBar.getWidth(), toolBar.getHeight());
lp.setMargins(0, 0, 0, 0);
appBarLayout.setLayoutParams(lp);
finalSlide.setFillAfter(true);
}
});
添加更多,如果你想这是最慢的。 –
我的意思是如何减慢底部到达顶部的时间。例如,当用户点击动画开始时,它会在4秒内到达顶部。 – Sean
slide = new TranslateAnimation(-100f,0f,0f,0f);主要是持续时间有帮助,但你可以试试 –