2016-06-12 8 views
0

mButtonがクリックされたときにsetmButtonのスピード(継続時間)を増やそうとしましたが、結果が表示されません。xButtonをx = 0からx = 100に移動してスピードを上げてください。 mButonのアニメーションは、x = 0から開始し、x = 100(duration = 10000)に移動します。これをクリックすると、mButtonで最終的な位置に速度が上がります。 はあなたがあなたが近端からのより高い速度レベルをしたいか、アニメーションが速くなりますので、単純に低い値に期間を設定した場合、補間を加速使用することができObjectAnimator onClickメソッドの速度を上げる方法は?

@TargetApi(Build.VERSION_CODES.HONEYCOMB) 
public void animationA() { 
    new Handler().postDelayed(new Runnable() { 
     @Override 
     public void run() { 

      final ImageButton mButton = (ImageButton)findViewById(R.id.Button); 
      assert mButton != null; 
      mButton.setBackgroundResource(R.drawable.Button); 




      ObjectAnimator mButtonAnimation= ObjectAnimator.ofFloat(mButton , "translationX", 0, -2100); 
      mButtonAnimation.setDuration(11000); 
      mButtonAnimation.setStartDelay(50); 
      mButtonAnimation.setRepeatCount(ObjectAnimator.INFINITE); 
      mButtonAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); 
      ObjectAnimator mButtonAnimation1 = ObjectAnimator.ofFloat(mButton, "alpha", 0, 1); 
      mButtonAnimation1 .setDuration(90); 

      mButtonAnimation1 .setInterpolator(new AccelerateDecelerateInterpolator()); 
      final AnimatorSet setmButton = new AnimatorSet(); 
      setmButton .playTogether(mButtonAnimatiea, mButtonAnimation1); 
      //setmButton .setFillAfter(true); 

      setmButton.start(); 






      mButton.setOnClickListener(new View.OnClickListener() { 
       @Override 
       public void onClick(View v) { 





        Handler handlermButton = new Handler(); 
        handlermButton.postDelayed(new Runnable() { 
         @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) 
         @Override 
         public void run() { 

          setmButton.setDuration(500); 


         } 
        }, 100); 

       } 
      }); 



     }}, 100); } 
+0

「スピード(継続時間)を増やそうとしています」「いいえ、スピード!=デュレーション、スピード**または**の時間を長くしたいですか? – pskink

+0

速度を上げる – Daniel

答えて

0

ありがとうございます。

+0

ボタンをクリックした後に速度を上げる必要があります – Daniel

+0

ボタンをクリックしたときに持続時間を低く設定できますか?または私はscaleCurrentDurationメソッドをテストしています。それが成功すれば私は戻ってきます:) –

+0

setmButton.setDuration(500);アニメーションの時間を変更しないで動作しています – Daniel

関連する問題