2017-08-24 304 views
0

我必須從x移動到y點。橫向有10個視圖。我想要移動一個圖像視圖以從x視圖移動到y視圖。將視圖從一個視圖移動到另一個視圖

TranslateAnimation animation = new TranslateAnimation(0, viewTwo.getX()-viewOne.getX(),0 , viewTwo.getY()-viewOne.getY()); 
    animation.setRepeatMode(0); 
    animation.setDuration(3000); 
    animation.setFillAfter(true); 
    viewOne.startAnimation(animation); 

但viewTwo.getX()和viewOne.getX()返回0.0。 enter image description here

回答

1

嘗試查找measure()方法獲取X位置值!
像,測量視圖,直到Y位置,Y位置左側的視圖寬度將是你想要的結果。

相關問題