Reputation: 1174
I want to set an Animated Vector Drawable to widget initial layout. The animation has many AnimationSet but it cannot set repeat together. It just can set repeat itself.
The following code animate the target vector "path1". I have 4 target but I cannot animate them together. They just can be repeat itself immediately.
I search a lot of answers. Much of them use listener to listener animationEnd callback. But I cannot set the callback to initial layout of widget.
ex.
<target android:name="path1">
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:propertyName="fillAlpha"
android:duration="100"
android:valueFrom="0"
android:valueTo="0"
andoird:repeatCount="-1"
android:valueType="floatType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="fillAlpha"
android:startOffset="5000"
android:duration="100"
android:valueFrom="1"
android:valueTo="1"
android:valueType="floatType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</set>
</aapt:attr>
</target>
Upvotes: 4
Views: 936
Reputation: 701
Actually yes! You can use the code below to set repeat for your animation.
android:repeatCount="infinite"
For example:
<objectAnimator
android:duration="1000"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:propertyName="trimPathStart"
android:valueFrom="0.9"
android:valueTo="0"
android:repeatCount="infinite"
android:valueType="floatType" />
And it just can be used in <objectAnimator>
not in <set>
.
Upvotes: 0