2
AnimatedVectorDrawableの逆順でアニメーションを再生することは可能ですか?AnimatedVectorDrawableでアニメーションを反転する
AnimatedVectorDrawableの逆順でアニメーションを再生することは可能ですか?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上で動作しますが、私はあなたがあなた自身の逆のアニメーションを作成する必要があると考えてい
'reverse();'メソッドはAPI24 –
:-(API24上では動作しません。私は、Androidが持っているとは思いません。あなたがそれを可能にする関数 – Stardust
@Stardustあなたは正しいです。私は2つの別々のアニメーションを実装しました –