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); 

     } 

    }); 

答えて

5

あなたは、これが最も遅いことにしたい場合は、よりを追加

slide =new TranslateAnimation(-100f, 0f, 0f, 0f); 
slide.setDuration(600); 
+0

、これを試してみてください。 –

+0

私は、ボトムが上になる時間を遅くする方法を意味しました。たとえば、ユーザーがアニメーションの開始をクリックすると、4秒以内に最下部まで到達します。 – Sean

+0

slide = new TranslateAnimation(-100f、0f、0f、0f);主にデュレーションが役立ちますが、 –

関連する問題