在AnimatedVectorDrawable中,是否可以以相反的顺序播放动画?
在AnimatedVectorDrawable中,是否可以以相反的顺序播放动画?
/**
* Reverses ongoing animations or starts pending animations in reverse.
* <p>
* NOTE: Only works if all animations support reverse. Otherwise, this will
* do nothing.
* @hide
*/
public void reverse()
private boolean mAnimationReversed = false;
public void startAnimation() {
if(mAnimationReversed) {
try {
Method reverse = mDrawable.getClass().getMethod("reverse");
reverse.invoke(mDrawable);
} catch (IllegalAccessException| NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
}
mDrawable.start();
mAnimationReversed = !mAnimationReversed;
}
刚刚验证:在API21上可以工作,但在API24上无法工作 :-(
reverse();
方法在 API24 中已经不再存在。 - Mark