Android AnimatedVectorDrawable-属性:FullPath不支持

Jua*_*via 2 android android-animation android-support-library

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

例外: Property: scaleX is not supported for FullPath

  • 使用android支持库: 27.0.2
  • Android牛轧糖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>
Run Code Online (Sandbox Code Playgroud)

Jua*_*via 6

由于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>
Run Code Online (Sandbox Code Playgroud)

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