微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将Tween与逐帧动画组合

如何解决将Tween与逐帧动画组合

| 我仍然对最基本的需求有疑问。 我想有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我能够克服它。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。