我在使用 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/