2011-05-23 83 views
1

我仍然有最基本的需求問題。 我想要2個按鈕:一個運行一個補間動畫,將圖像移動50個像素,另一個按鈕在該圖像上通過幀動畫運行一幀。結合補間和逐幀動畫

補間動畫完成後,逐幀動畫會在錯誤的位置運行。奇怪的。 我使用FillAfter/FillEnabled,

代碼運行補間動畫是一個基本 TranslateAnimation(0,50,0,0)與填充後和fillEnabled =真。

frame by frame code is image.setImageDrawable(getResources()。getDrawable(resourceId)); ((AnimationDrawable)image.getDrawable())。start();

幫助將不勝感激。

乾杯

回答

2

,我發現這樣做的唯一事情是這樣的 首先您移動imageview的位置,使用setLayoutParams新的利潤, 才把你使用啓動TranslateAnimation(-x,-y,0 ,0)所以對於我的具體情況的問題,這裏是我的代碼:

TranslateAnimation tweenAnim = new TranslateAnimation(-1 * XStep, -1 * YStep , 0, 0); 
tweenAnim.setDuration(number_of_steps * 750); 
tweenAnim.setFillAfter(true); 
tweenAnim.setFillEnabled(true); 
tweenAnim.setInterpolator(new LinearInterpolator()); 

//layout positioning 
lp.leftMargin += XStep; 
lp.bottomMargin += YStep; 
imageView.setLayoutParams(lp); 

Log.v(TAG, "leftMargin=" + lp.leftMargin); 
Log.v(TAG, "bottomMargin=" + lp.bottomMargin); 

imageView.startAnimation(tweenAnim); 

這是一個巨大的痛苦。認真。 感謝http://www.clingmarks.com/?p=400我能夠克服它。