2017-01-20 9 views
-3

私はボタンをポイントAからポイントBに移動しようとしていますが、私はジャンプではなくソフトな動きが必要です。トランジションのように。どうすればいいですか?AndroidスタジオでポイントAからポイントBにボトルトンを移動するにはどうすればよいですか?

+0

your_button.animate()。x(50f).y(100f);あなたが望むようにxとyの値を保つ – 44kksharma

+0

ありがとう、しかし、速度を制御する方法をtheres? –

答えて

0
 make changes as per your need 


     Animation animation = new TranslateAnimation(0, 500,0, 0); 
     animation.setDuration(1000); 
     animation.setFillAfter(true); 
     yourButton.startAnimation(animation); 
     yourButton.setVisibility(0); 

    OR 
    You can create Translate animation using ObjectAnimator. check link for more information 

    ObjectAnimator transAnimation= ObjectAnimator.ofFloat(YourButton, propertyName, fromX, toX); 
    transAnimation.setDuration(3000);//set duration 
    transAnimation.start();//start animation 

Example 
ObjectAnimator anim = ObjectAnimator.ofFloat(yourButton, "translationX", 0,200); and then 
anim.setDuration(3000); 
anim.start(); 
+0

それは私がほしいと思うexatly、ありがとう:) –

関連する問題