问题描述
|
我仍然对最基本的需求有疑问。
我想有2个按钮:一个运行补间动画,可将图像移动50像素,另一个按钮可在该图像上运行逐帧动画。
补间动画完成后,逐帧动画将在错误的位置运行。奇怪的。
我正在使用FillAfter / FillEnabled,
运行补间动画的代码是基本的
TranslateAnimation(0,50,0,0)在fill和fillEnabled = true之后填充。
逐帧代码是
image.setimageDrawable(getResources()。getDrawable(resourceId));
(((AnimationDrawable)image.getDrawable())。start();
帮助将不胜感激。
干杯
解决方法
我发现这样做的唯一方法是
首先,使用带有新边距的setLayoutParams移动图像视图位置,
然后才使用(-x,-y,0,0)启动TranslateAnimation,因此对于我在问题中的特殊情况,这是我的代码:
TranslateAnimation tweenAnim = new TranslateAnimation(-1 * XStep,-1 * YStep,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我能够克服它。