重置机器人动画效果 [英] reset animation effects in android

查看:146
本文介绍了重置机器人动画效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我表演上的一个按钮淡入淡出的效果。

I am performing a fade effect on a button.

AnimationSet set = new AnimationSet(true);
Animation animation2 = new AlphaAnimation((float) 0, 1);
animation2.setDuration(1500);
animation2.setRepeatMode(0);
set.addAnimation(animation2);
set.setFillAfter(true); // leaves the animation in its final status
btn.startAnimation(set);

我使用的是 setFillAfter(真)选项离开按钮可见。这工作正常。现在我想再次执行动画,,但不能永远不会再为我设置按钮在屏幕上看不见,除非我重新启动应用程序。 (ALOS试过无效(),但没有成功...)

I am using the setFillAfter(true) option to leave the button visible. That works fine. Now I would like to perform the animation again, but can't never set again my button to be invisible on the screen, unless I restart the app. (alos tried invalidate() with no success...)

任何想法将是如此的欢迎。

Any idea would be "so" welcome.

在此先感谢!
保罗

Thanks in advance! Paul

推荐答案

感谢您对您有所帮助。其实我发现了developpers DOC答案。有观看动画(我试图做的)和属性动画有很大的区别。基本上看动画重绘您正在使用的视图的形象,但不影响原来的看法。所以,如果你翻译例如,从您的看法,屏幕上的看法是移动,但编程它仍然在它的初始状态,并会赶上事件在其原来的位置。

Thank you for you help. Actually I found the answer on the developpers doc. There is a big difference between "View animation" (which I tried to do) and "Property Animation". Basically View animation redraws an image of the view you are working on, but does not affect the original view. So If you translate your view from example, on the screen the view is moved but programatically it remained in its initial state and will catch events in its original position.

下面的解释是:

如何物业动画从观看动画的观点不同,动画
  系统提供的能力只有动画视图对象,因此,如果您
  希望动画非View对象,必须实现自己的
  code这样做。视图动画系统也是制约在
  事实上,它只是暴露了一个视图对象的几个方面进行动画,
  如视图的缩放和旋转,但不是背景
  颜色,例如。

How Property Animation Differs from View Animation The view animation system provides the capability to only animate View objects, so if you wanted to animate non-View objects, you have to implement your own code to do so. The view animation system is also constrained in the fact that it only exposes a few aspects of a View object to animate, such as the scaling and rotation of a View but not the background color, for instance.

视图动画系统的另一个缺点是,只有它
  修改,其视图被吸引,而不是实际的观本身。对于
  例如,如果你设置动画的按钮在屏幕上移动时,
  按钮画正确,但实际位置,你可以点击
  该按钮不会改变,所以你要实现你自己的逻辑来
  处理这个问题。

Another disadvantage of the view animation system is that it only modified where the View was drawn, and not the actual View itself. For instance, if you animated a button to move across the screen, the button draws correctly, but the actual location where you can click the button does not change, so you have to implement your own logic to handle this.

使用属性动画系统,这些限制是完全
  删除,您可以动画的任何对象(查看任何财产,
  非查看)和对象本身实际上被修改。该物业
  动画系统也是它执行的方式更加强劲
  动画。在一个较高的水平,分配动画师的属性
  要进行动画,如颜色,位置,或尺寸和能
  定义如插补动画的方面和
  多个动画师的同步。

With the property animation system, these constraints are completely removed, and you can animate any property of any object (Views and non-Views) and the object itself is actually modified. The property animation system is also more robust in the way it carries out animation. At a high level, you assign animators to the properties that you want to animate, such as color, position, or size and can define aspects of the animation such as interpolation and synchronization of multiple animators.

该视图的动画系统,但是,花费较少的时间设置和
  需要较少的code写的。如果观看动画完成一切
  你需要做的,或者如果您现有的code已经工作方式
  要,也没有必要使用属性动画系统。它
  也可能是有意义的使用两种不同的动画系统
  如果用例出现的情况。

The view animation system, however, takes less time to setup and requires less code to write. If view animation accomplishes everything that you need to do, or if your existing code already works the way you want, there is no need to use the property animation system. It also might make sense to use both animation systems for different situations if the use case arises.

http://developer.android.com/guide/topics/图形/道具-animation.html

有关我的情况下我用房产动画和我的一切需求的动画相匹配。谢谢你的支持!
:)

For my case I used Property animation and it matches all my animation needs. Thank you for your support! :)

这篇关于重置机器人动画效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆