I want to animate my
AnimatedVectorDrawable at runtime without using
.xml files. Actually I’m using
.xml files same way as documentation’s samples shows:
So, I have
<vector> with nested
<path> which defines a shape.
For this vector I have
android:animation assinged to
Last step is define an animation file
<objectAnimator> which is used by
Everything works fine, but the problem appears, when I need to create many different shapes (vectors) with many different or similar animations, because this generate many
I can’t include ready and prepared
.xmlfile to another (some kind of
<include>tag) so i need to copy the same code to another files. It is very annoying.
If I want to use the same animation for few
<target>elements but each animation must have f.e. different delay or any property value (
interpolator…) , I must create new
<objectAnimator>with changed one property value instead of use the same, one file with changed property value. It’s also annoying.
I discovered that I can use
AnimatedVectorDrawablebut there is a problem when I want to change it’s
rotationor any other properties. Is there a way to do this without
.xml. I just want to have access to
Constructor that you used creates animation with absolute values (pixels).
TranslateAnimation in = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, 0, 0.0f, 0, 0.0f);
Try use Animation.RELATIVE_TO_PARENT to fit your needs.