Android AnimatedVectorDrawable - 属性 : is not supported for FullPath

标签 android android-animation android-support-library

我在使用 Android AnimatedVectorDrawableCompat 时遇到这个特定错误:

异常:属性:FullPath 不支持 scaleX

  • 使用安卓支持库:27.0.2
  • Android 牛轧糖 SDK

但相同的动画适用于较旧的操作系统版本。

动画

<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>

最佳答案

自从 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

关于Android AnimatedVectorDrawable - 属性 : is not supported for FullPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51794244/

相关文章:

java - 如何在Android上通过蓝牙发送字节数组?

Android 支持 EditTextPreference 输入类型

android - 错误: Activity class {} does not exist (only on specific phone)

android - Android 上的 JQuery Mobile/Phonegap - 所有文本均以大写形式显示

android - 工具栏返回动画

android - viewflipper 中 surfaceview 的渲染问题?

java - 如何使用 Android 动画播放 'Tick Tick' 声音(可能使用 `Android MediaPlayer/SoundPool` )?

android - ExpandableListFragment 与 LoaderManager 兼容包

android - Android 中 ViewPager 的替代方案

android - ionic 3 cli 'ionic cordova run android' 命令抛出错误