Android AnimatedVectorDrawable-属性:FullPath不支持

时间:2018-08-10 21:29:35

标签: android android-animation android-support-library

我使用Android AnimatedVectorDrawableCompat有此特定错误:

例外:Property: scaleX is not supported for FullPath

  • 使用android支持库:27.0.2
  • Android Nougat SDK

但是相同的动画适用于较早的OS版本。

动画

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="54dp"
        android:height="2dp"
        android:viewportHeight="2.0"
        android:viewportWidth="54.0">

    <!-- Green Line -->
    <path
        android:name="line_green"
        android:pathData="M 0,0 L 54,0 Z"
        android:strokeAlpha="0"
        android:strokeColor="@color/green_color"
        android:strokeWidth="2"/>

</vector>

1 个答案:

答案 0 :(得分:4)

由于Android Nougat并支持lib 27.0.x,所以AnimatedVectorsDrawable的工作方式有所变化,您需要将项目矢量放入组中,并将“名称”设置为组,然后从路径中将其删除,以便应用动画加入小组。

    <!-- Green Line -->
    <group
        android:name="line_green"
        android:strokeAlpha="0">
        <path
            android:pathData="M 0,0 L 54,0 Z"
            android:strokeColor="@color/green_color"
            android:strokeWidth="2"/>
    </group>

我在以下github线程中找到了解决方案:https://github.com/nickbutcher/plaid/issues/132