The answer is yes, they do work, just probably not for what you expect - for instance, the description for setFillAfter(boolean fillAfter)
says
If fillAfter is true, the
transformation that this animation
performed will persist when it is
finished.
and when set to true it does do this.
However, unintuitively an animation on Android does not actually animate the View itself, rather it animates a bitmap representation of the View.
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.
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…