Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - objectAnimator xml alpha animation not working

Using alpha as the propertyName of the objectAnimator does nothing at all. The objectAnimator is connected to a path inside the vector.

fading_animator.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <objectAnimator
        android:duration="700"
        android:propertyName="alpha"
        android:valueFrom="1"
        android:valueTo="0"
        android:valueType="floatType"
        android:repeatCount="infinite"
        android:repeatMode="restart"/>
</set>

animated_vector.xml:

<animated-vector
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:drawable="@drawable/vector_drawable">

  <target
    android:name="pathTarget"
    android:animation="@animator/fading_animator"/>

</animated-vector>
like image 522
neits Avatar asked Dec 24 '22 21:12

neits


1 Answers

When trying to animate the alpha of a path, you have to use either fillAlpha or strokeAlpha. Similarly, scaleX and scaleY will not work on a path but it will work on a group inside the vector.

like image 100
neits Avatar answered Dec 31 '22 06:12

neits