是否可以以相反的顺序播放AnimatedVectorDrawable的动画?
答案 0 :(得分:0)
如果您查看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: - (