Reputation: 179
How can I control the speed of the animation? The translate animation goes from bottom to top and I'd like to slow down the animation during the time its being executed. How can I achieve this? Here is what I have:
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);
}
});
Upvotes: 1
Views: 1016
Reputation: 2962
Try this,
slide =new TranslateAnimation(-100f, 0f, 0f, 0f);
slide.setDuration(600);
Upvotes: 5