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:
AnimatedVectorDrawable
So, I have vector_drawable.xml
contains<vector>
with nested <group>
and <path>
which defines a shape.
For this vector I have animated_vector_drawable.xml
contains <animated-vector>
with android:animation
assinged to <target>
.
Last step is define an animation file rotation.xml
using <objectAnimator>
which is used by animated_vector_drawable.xml
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 .xml
files.
I can't include ready and prepared
<vector>
from one.xml
file 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 (alpha
,rotation
,interpolator
...) , I must create new.xml
file contains<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
ObjectAnimator
and setalpha
&fillColor
forAnimatedVectorDrawable
but there is a problem when I want to change it'stranslateX
,translateY
,rotation
or any other properties. Is there a way to do this without.xml
. I just want to have access to<group>