【发布时间】:2017-05-20 22:55:56
【问题描述】:
如何控制动画的速度?翻译动画从底部到顶部,我想在动画执行期间放慢动画速度。我怎样才能做到这一点?这是我所拥有的:
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);
}
});
【问题讨论】:
标签: java android android-animation android-coordinatorlayout