Animated Vector Drawable:objectAnimator不并行运行

时间:2018-12-10 13:06:39

标签: android android-animation android-xml android-vectordrawable

我有下面的XML文件,其中包含动画矢量。

它为WiFi符号波设置动画。有4个波浪,每个波浪需要1秒出现,并且一个接一个地动画,从alpha = 0到alpha = 1,因此可见。

问题在于,它们出现后,我希望所有人都同时将其动画为alpha = 0,而不是一个接一个地动画。

我向每个具有相同startOffset和持续时间的目标添加了一个额外的objectAnimator,但是它不起作用,因为它们仍然一个接一个地消失。

<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt">
    <aapt:attr name="android:drawable">
        <vector
            android:name="vector"
            android:width="272dp"
            android:height="139dp"
            android:viewportHeight="139"
            android:viewportWidth="272">
            <path
                android:name="path"
                android:fillAlpha="0"
                android:fillColor="#218bf2"
                android:fillType="evenOdd"
                android:pathData="M 123.735 63.9 C 122.093 65.539 121.057 67.689 120.796 69.994 C 120.535 72.3 121.065 74.626 122.299 76.591 C 123.533 78.556 125.398 80.044 127.588 80.811 C 129.778 81.577 132.164 81.577 134.354 80.811 C 136.544 80.044 138.409 78.556 139.643 76.591 C 140.877 74.626 141.407 72.3 141.146 69.994 C 140.885 67.689 139.849 65.539 138.207 63.9 C 136.286 61.987 133.682 60.913 130.971 60.913 C 128.26 60.913 125.656 61.987 123.735 63.9 Z"
                android:strokeAlpha="0"
                android:strokeMiterLimit="1" />
            <path
                android:name="path_1"
                android:fillAlpha="0"
                android:fillColor="#218bf2"
                android:fillType="evenOdd"
                android:pathData="M 130.971 39.532 C 126.823 39.521 122.714 40.334 118.883 41.923 C 115.052 43.512 111.574 45.847 108.652 48.791 C 107.743 49.682 107.14 50.84 106.933 52.096 C 106.726 53.352 106.924 54.643 107.499 55.778 C 108.075 56.914 108.997 57.838 110.132 58.415 C 111.267 58.991 112.557 59.191 113.813 58.986 C 115.07 58.781 116.229 58.18 117.121 57.272 C 119.55 54.837 122.579 53.086 125.9 52.195 C 129.222 51.303 132.72 51.303 136.042 52.195 C 139.363 53.086 142.392 54.837 144.821 57.272 C 145.949 58.377 147.469 58.993 149.048 58.984 C 150.627 58.976 152.14 58.343 153.256 57.226 C 154.372 56.109 155.002 54.595 155.008 53.016 C 155.015 51.437 154.397 49.917 153.29 48.791 C 150.368 45.847 146.89 43.512 143.059 41.923 C 139.228 40.334 135.119 39.521 130.971 39.532 Z"
                android:strokeAlpha="0"
                android:strokeMiterLimit="1" />
            <path
                android:name="path_2"
                android:fillAlpha="0"
                android:fillColor="#218bf2"
                android:fillType="evenOdd"
                android:pathData="M 130.971 19.784 C 124.231 19.766 117.553 21.086 111.327 23.668 C 105.101 26.251 99.449 30.044 94.7 34.827 C 93.791 35.718 93.188 36.876 92.981 38.132 C 92.774 39.388 92.972 40.679 93.547 41.814 C 94.123 42.95 95.045 43.874 96.18 44.451 C 97.315 45.027 98.605 45.227 99.861 45.022 C 101.118 44.817 102.277 44.216 103.169 43.308 C 108.044 38.423 114.122 34.908 120.788 33.12 C 127.454 31.331 134.476 31.331 141.142 33.12 C 147.808 34.908 153.886 38.423 158.761 43.308 C 159.653 44.216 160.812 44.817 162.069 45.022 C 163.325 45.227 164.615 45.027 165.75 44.451 C 166.885 43.874 167.807 42.95 168.383 41.814 C 168.958 40.679 169.156 39.388 168.949 38.132 C 168.742 36.876 168.139 35.718 167.23 34.827 C 162.483 30.045 156.833 26.252 150.609 23.67 C 144.385 21.088 137.709 19.767 130.971 19.784 Z"
                android:strokeMiterLimit="1"
                android:strokeWidth="1" />
            <path
                android:name="path_3"
                android:fillAlpha="0"
                android:fillColor="#218bf2"
                android:fillType="evenOdd"
                android:pathData="M 181.214 20.834 C 172.401 12.004 161.415 5.651 149.366 2.418 C 137.317 -0.815 124.625 -0.815 112.576 2.418 C 100.527 5.651 89.541 12.004 80.728 20.834 C 79.832 21.728 79.242 22.883 79.043 24.133 C 78.844 25.383 79.046 26.665 79.62 27.793 C 80.194 28.921 81.111 29.839 82.238 30.414 C 83.365 30.989 84.646 31.193 85.896 30.995 C 87.147 30.798 88.303 30.21 89.198 29.315 C 96.524 21.973 105.658 16.691 115.676 14.003 C 125.693 11.315 136.245 11.315 146.262 14.003 C 156.28 16.691 165.414 21.973 172.74 29.315 C 173.865 30.432 175.39 31.059 176.976 31.056 C 178.562 31.052 180.083 30.42 181.204 29.298 C 182.325 28.176 182.956 26.654 182.958 25.068 C 182.96 23.482 182.332 21.959 181.214 20.834 Z"

                android:strokeAlpha="0"
                android:strokeMiterLimit="1" />
            <path
                android:name="path_4"
                android:fillColor="#ffffff"
                android:fillType="evenOdd"
                android:pathData="M 41.974 100.751 C 39.586 99.735 37.126 98.899 34.613 98.251 Q 33.179 97.867 27.061 96.425 C 23.698 95.766 20.402 94.801 17.214 93.542 Q 12.147 91.237 12.148 86.623 C 12.115 85.079 12.542 83.559 13.377 82.259 C 14.211 80.958 15.414 79.936 16.832 79.323 L 16.732 79.323 C 19.751 78.036 23.011 77.413 26.292 77.494 Q 38.624 77.494 40.823 87.023 Q 41.396 89.623 45.223 89.623 C 46.309 89.609 47.381 89.38 48.378 88.949 Q 50.96 87.89 50.959 86.254 C 50.964 83.192 50.03 80.202 48.282 77.688 L 48.282 77.788 Q 41.782 67.876 26.008 67.874 C 23.832 67.866 21.659 68.026 19.508 68.354 Q 9.947 69.989 4.977 76.812 C 2.83 79.838 1.722 83.481 1.823 87.19 Q 1.823 97.472 11.669 102.662 C 13.335 103.493 15.061 104.199 16.831 104.775 Q 19.889 105.834 26.582 107.375 C 29.849 108.126 33.072 109.056 36.237 110.162 Q 43.407 112.756 43.407 118.715 C 43.426 120.572 42.857 122.389 41.782 123.903 Q 38.147 129.093 28.016 129.093 C 24.651 129.096 21.313 128.48 18.17 127.278 Q 11.19 124.602 10.139 118.578 Q 9.661 115.902 5.646 115.903 C 4.416 115.908 3.203 116.204 2.109 116.766 Q 0.009 117.725 0.009 119.353 L 0.009 119.641 C 0.339 122.597 1.389 125.428 3.068 127.884 Q 10.236 139 28.4 139 C 32.918 139.042 37.391 138.089 41.5 136.21 C 45.092 134.619 48.183 132.077 50.438 128.859 C 52.638 125.688 53.792 121.906 53.738 118.047 Q 53.738 106.132 41.98 100.747 Z M 114.531 79.9 Q 110.515 71.527 100.478 69.7 C 97.093 69.192 93.672 68.967 90.25 69.026 L 67.593 69.026 L 67.593 134.957 Q 67.593 136.498 70.079 137.845 C 71.188 138.368 72.391 138.663 73.616 138.711 Q 77.632 138.711 78.205 134.861 L 78.205 110.7 L 91.015 110.7 Q 116.539 110.7 116.539 89.333 C 116.584 86.078 115.898 82.854 114.531 79.9 Z M 91.206 100.979 L 78.206 100.979 L 78.206 78.937 L 91.016 78.937 C 93.61 78.843 96.207 79.035 98.759 79.511 C 100.889 80.062 102.734 81.398 103.921 83.25 C 105.19 85.148 105.857 87.387 105.833 89.67 Q 105.833 100.978 91.207 100.978 Z M 137 89.813 Q 137 87.119 132.411 87.118 Q 128.011 87.118 128.011 89.813 L 128.011 136.68 Q 128.011 138.99 132.217 138.99 Q 136.996 138.99 136.997 136.777 L 136.997 89.813 Z M 204.872 86.926 Q 199.804 73.066 186.708 69.986 C 182.771 69.238 178.765 68.915 174.759 69.023 L 151.906 69.023 L 151.906 137.938 L 175.906 137.938 C 179.54 137.995 183.166 137.607 186.706 136.784 C 190.203 135.989 193.482 134.431 196.307 132.222 C 199.133 130.014 201.436 127.208 203.053 124.007 Q 207.546 115.652 207.546 103.162 C 207.695 97.629 206.787 92.118 204.87 86.926 Z M 190.437 123.693 Q 186.037 128.218 174.855 128.217 L 162.613 128.217 L 162.613 78.937 L 174.658 78.937 Q 182.115 78.937 185.652 80.092 L 185.552 80.092 Q 196.738 84.328 196.737 102.999 Q 196.737 117.244 190.428 123.693 Z M 260.6 100.751 C 258.212 99.735 255.752 98.899 253.239 98.251 Q 251.805 97.867 245.687 96.425 C 242.324 95.766 239.028 94.801 235.841 93.542 Q 230.773 91.237 230.774 86.623 C 230.74 85.078 231.168 83.558 232.003 82.258 C 232.837 80.958 234.041 79.936 235.459 79.323 L 235.359 79.323 C 238.378 78.036 241.638 77.413 244.918 77.494 Q 257.251 77.494 259.449 87.023 Q 260.024 89.623 263.849 89.623 C 264.935 89.609 266.007 89.38 267.003 88.949 Q 269.585 87.89 269.584 86.254 C 269.589 83.193 268.655 80.202 266.908 77.688 L 266.908 77.788 Q 260.408 67.876 244.634 67.874 C 242.458 67.866 240.285 68.026 238.134 68.354 Q 228.573 69.989 223.603 76.812 C 221.456 79.838 220.349 83.481 220.449 87.19 Q 220.449 97.472 230.295 102.662 C 231.961 103.493 233.687 104.199 235.458 104.775 Q 238.515 105.834 245.208 107.375 C 248.476 108.126 251.699 109.056 254.864 110.162 Q 262.032 112.756 262.033 118.715 C 262.052 120.572 261.483 122.389 260.408 123.903 Q 256.773 129.093 246.642 129.093 C 243.277 129.095 239.939 128.48 236.796 127.278 Q 229.816 124.602 228.766 118.578 Q 228.286 115.902 224.273 115.903 C 223.042 115.908 221.83 116.203 220.736 116.766 Q 218.636 117.725 218.636 119.353 L 218.636 119.641 C 218.966 122.597 220.017 125.428 221.696 127.884 Q 228.862 139 247.025 139 C 251.543 139.043 256.016 138.091 260.125 136.213 C 263.718 134.622 266.808 132.08 269.063 128.862 C 271.263 125.691 272.417 121.909 272.363 118.05 Q 272.363 106.135 260.604 100.75 Z"
                android:strokeAlpha="0" />
        </vector>
    </aapt:attr>


    <target android:name="path">
        <aapt:attr name="android:animation">
            <set>
                <objectAnimator
                    android:duration="1000"
                    android:interpolator="@android:interpolator/fast_out_slow_in"
                    android:propertyName="fillAlpha"
                    android:valueFrom="0"
                    android:valueTo="1"

                    android:valueType="floatType" />

                <objectAnimator
                    android:duration="1000"
                    android:interpolator="@android:interpolator/fast_out_slow_in"
                    android:propertyName="fillAlpha"
                    android:startOffset="4000"
                    android:valueFrom="1"
                    android:valueTo="0"
                    android:valueType="floatType" />
            </set>

        </aapt:attr>

    </target>
    <target android:name="path_1">
        <aapt:attr name="android:animation">

            <set>
                <objectAnimator
                    android:duration="1000"
                    android:interpolator="@android:interpolator/fast_out_slow_in"
                    android:propertyName="fillAlpha"
                    android:startOffset="1000"
                    android:valueFrom="0"
                    android:valueTo="1"

                    android:valueType="floatType" />

                <objectAnimator
                    android:duration="1000"
                    android:interpolator="@android:interpolator/fast_out_slow_in"
                    android:propertyName="fillAlpha"
                    android:startOffset="4000"
                    android:valueFrom="1"
                    android:valueTo="0"
                    android:valueType="floatType" />
            </set>

        </aapt:attr>
    </target>
    <target android:name="path_2">
        <aapt:attr name="android:animation">
            <set>
                <objectAnimator
                    android:duration="1000"
                    android:interpolator="@android:interpolator/fast_out_slow_in"
                    android:propertyName="fillAlpha"
                    android:startOffset="2000"
                    android:valueFrom="0"
                    android:valueTo="1"

                    android:valueType="floatType" />

                <objectAnimator
                    android:duration="1000"
                    android:interpolator="@android:interpolator/fast_out_slow_in"
                    android:propertyName="fillAlpha"
                    android:startOffset="4000"
                    android:valueFrom="1"
                    android:valueTo="0"
                    android:valueType="floatType" />

            </set>

        </aapt:attr>
    </target>

    <target android:name="path_3">
        <aapt:attr name="android:animation">
            <set>
                <objectAnimator
                    android:duration="1000"
                    android:interpolator="@android:interpolator/fast_out_slow_in"
                    android:propertyName="fillAlpha"
                    android:startOffset="3000"
                    android:valueFrom="0"
                    android:valueTo="1"

                    android:valueType="floatType" />

                <objectAnimator
                    android:duration="1000"
                    android:interpolator="@android:interpolator/fast_out_slow_in"
                    android:propertyName="fillAlpha"
                    android:startOffset="4000"
                    android:valueFrom="1"
                    android:valueTo="0"
                    android:valueType="floatType" />
            </set>

        </aapt:attr>
    </target>

</animated-vector>

0 个答案:

没有答案