我試圖使用動畫將圖像從一個地方移動到另一個地方,但在移動它回到原始位置之後,如何將其停止到移動的位置本身。Android動畫
0
A
回答
0
見this blog post for a solution:
// first set the view's location to the end position
view.setLayoutParams(...); // set to (x, y)
// then animate the view translating from (0, 0)
TranslationAnimation ta = new TranslateAnimation(-x, -y, 0, 0);
ta.setDuration(1000);
view.startAnimation(ta);
1
讓在動畫的最後一個地方的形象,試試這個:
TranslationAnimation ta = new TranslateAnimation(fromX, toX, 0, 0);
ta.setDuration(1000);
ta.setFillAfter(true); // this will let the image in the last place of the Animation
imageView.startAnimation(ta);
0
我相信你應該已經找到了答案(我只是...所以我張貼給其他人)。 Android似乎已經正式轉向了名爲「Property Animation」的新動畫框架。自從Honeycomb(3.0)以來,這已經可用。這將基本上解決您的問題,因爲它動畫的實際屬性值。
開發指南:一個動畫完成 http://developer.android.com/guide/topics/graphics/prop-animation.html
1
後,使用方法setFillAfter(真),使最後的動畫狀態仍然存在:
如果fillAfter是真實的,轉型,這執行完成後的動畫將保持不變。
Animation.setFillAfter/Before - Do they work/What are they for?
如果您需要做更具體的東西,你也可以設置一個動畫監聽器,並在動畫的最後移動你的對象:
animation1.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
//change according to your needs
myView.setX(0);
}
@Override
public void onAnimationRepeat(Animation animation) { }
});
相關問題
- 1. Android動畫動畫列表動畫
- 2. android動畫:動畫行
- 3. Android:自動動畫
- 4. %android png動畫
- 5. Android ViewFlipper動畫
- 6. Android jpg動畫
- 7. android scrollview動畫
- 8. android動畫?
- 9. Android cocos2d動畫
- 10. Android:動畫gif
- 11. Android 3D動畫
- 12. Android setMaxLines動畫
- 13. Android動畫ShapeDrawable
- 14. Snackbar動畫android
- 15. Android:動畫
- 16. Android動畫
- 17. 的Android動畫
- 18. Android動畫GIF
- 19. Android動畫 - 選擇動畫時
- 20. 啓動畫面的Android圖像動畫
- 21. Android - 啓動畫面的淡出動畫
- 22. android中的動畫
- 23. 多層android動畫
- 24. Android旋轉動畫
- 25. Android多個動畫
- 26. libGDX動畫爲Android
- 27. android - 動畫形狀
- 28. Android動畫 - 逐幀?
- 29. Android動畫「滾入」
- 30. 動畫噸Android上
顯示代碼,請! – 2011-05-24 12:57:44