2011-05-23 64 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我能够克服它。