2012-07-06 9 views

cevap

4

bir TranslateAnimation kullanın:

TranslateAnimation animation = new TranslateAnimation(start_x, start_y, end_x, end_y); 
animation.setDuration(1000); // duartion in ms 
animation.setFillAfter(false); 
button.startAnimation(animation); 

ben işe yarayabilir pozisyonu, button.getTop() ve button.getLeft() var alabilirsiniz emin değilim ... eğer

+0

Nedenini bilmiyorum ama button.getTop() ve button.getLeft() hem 0. –

+0

teşekkür ederiz @ D-32 değerini verir daha fazla bilgi sağlamak android belgeler var TranslateAnimation kesinlikle iyi çalışıyor düğme hareket ediyor. –

+0

Xml'nizi düğmeyle sorunuza sokabilir misiniz? –

0
Solution for those who are looking for left to right animation) 

      TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 1500.0f); // new TranslateAnimation (float fromXDelta,float toXDelta, float fromYDelta, float toYDelta) 

       animation.setDuration(1500); // animation duration 
       animation.setRepeatCount(1); // animation repeat count 
      animation.setFillAfter(false); 
       your_view .startAnimation(animation);//your_view for mine is imageView  


Solution for those who are looking for repeated animation(for eg. left to right and right to left) 

      TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 1500.0f); // new TranslateAnimation (float fromXDelta,float toXDelta, float fromYDelta, float toYDelta) 
       animation.setDuration(1500); // animation duration 
       animation.setRepeatCount(4); // animation repeat count 
       animation.setRepeatMode(2); // repeat animation (left to right, right to left) 

       animation.setFillAfter(true); 
       your_view .startAnimation(animation);//your_view for mine is imageView 
İlgili konular