Animation.setFillAfter /前 - 做他们的工作/它们是什么呢?他们的、什么呢、工作、Animation

2023-09-12 02:49:10 作者:聚散不由你我

正如我的问题标题什么方法setFillBefore /()后该怎么办?我希望setFillAfter会作出改变,以查看永久后动画已经完成,但是这是不正确的?

As in the title of my question what do the methods setFillBefore/After() supposed to do? I was hoping setFillAfter would make the change to the View permanent after an animation has completed but this is incorrect?

感谢

推荐答案

答案是肯定的,他们做的工作,只是可能不是你所期望的 - 例如,对 setFillAfter描述(布尔fillAfter )表示,

The answer is yes, they do work, just probably not for what you expect - for instance, the description for setFillAfter(boolean fillAfter) says

如果fillAfter为真,   改造这个动画   执行将继续存在时,它是   完蛋了。

If fillAfter is true, the transformation that this animation performed will persist when it is finished.

和当设置为true,则做到这一点。

and when set to true it does do this.

不过,unintuitively在Android上的动画实际上没有动画视图本身,而是动画视图的位图重新presentation。

However, unintuitively an animation on Android does not actually animate the View itself, rather it animates a bitmap representation of the View.

你可能遇到的问题是一个动画后,视图可以追溯到是它是怎么动画之前 - setFillAfter setFillBefore 能不能帮你的,因为在这种情况下你真正想要做的是设置视图的属性是一样的动画再presentation(它们是独立的事情),而 setFillAfter setFillBefore 只适用于动画属性,无法查看属性。

The issue you are probably having is that after an animation the View goes back to being how it was before the animation - setFillAfter and setFillBefore cannot help you with that, because in that situation what you really want to do is set the properties of the View to be same as the animated representation (they are separate things), and setFillAfter and setFillBefore only apply to animation properties, not View properties.

它们存在的原因是链接的动画。假设你有一个翻译的动画随后淡出。如果您没有设置 setFillAfter(真)的翻译动画,然后在视图将转变,跳回到它原来的位置,然后淡出。随着 setFillAfter(真)的转换动画设置,视图将移动,然后淡出,在它的当前位置。

The reason they exist is for chaining animations. Suppose you had a translate animation followed by a fade out. If you did not set setFillAfter(true) on the translate animation, then the View would translate, jump back to it's original position and then fade out. With setFillAfter(true) set on the translate animation, the view will move and then fade out at it's current spot.