动画SVG文件未设置动画

时间:2019-05-06 20:52:09

标签: android svg android-animation android-vectordrawable

我有一个动画的.SVG,可以在浏览器中完美制作动画,但是当我通过Vector Asset Studio将其导入Andoroid Studio时,它将变成一个没有动画的平面单色图像。如何防止Android Studio破坏文件?

.xml文件将其转换为:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="200dp"
    android:height="200dp"
    android:viewportWidth="100"
    android:viewportHeight="100">
  <path
      android:pathData="M50,21.5L50,21.5A3,2.15 0,0 1,53 23.65L53,36.35A3,2.15 0,0 1,50 38.5L50,38.5A3,2.15 0,0 1,47 36.35L47,23.65A3,2.15 0,0 1,50 21.5z"
      android:fillColor="#91979b"/>
  <path
      android:pathData="M66.752,26.943L66.752,26.943A2.15,3 126,0 1,67.915 30.446L60.45,40.72A2.15,3 126,0 1,56.76 40.696L56.76,40.696A2.15,3 126,0 1,55.596 37.194L63.061,26.919A2.15,3 126,0 1,66.752 26.943z"
      android:fillColor="#91979b"/>
  <path
      android:pathData="M77.105,41.193L77.105,41.193A3,2.15 72,0 1,75.987 44.711L63.909,48.635A3,2.15 72,0 1,60.937 46.446L60.937,46.446A3,2.15 72,0 1,62.055 42.929L74.133,39.004A3,2.15 72,0 1,77.105 41.193z"
      android:fillColor="#91979b"/>
  <path
      android:pathData="M77.105,58.807L77.105,58.807A3,2.15 108,0 1,74.133 60.996L62.055,57.071A3,2.15 108,0 1,60.937 53.554L60.937,53.554A3,2.15 108,0 1,63.909 51.365L75.987,55.289A3,2.15 108,0 1,77.105 58.807z"
      android:fillColor="#91979b"/>
  <path
      android:pathData="M66.752,73.057L66.752,73.057A2.15,3 54,0 1,63.061 73.081L55.596,62.806A2.15,3 54,0 1,56.76 59.304L56.76,59.304A2.15,3 54,0 1,60.45 59.28L67.915,69.554A2.15,3 54,0 1,66.752 73.057z"
      android:fillColor="#91979b"/>
  <path
      android:pathData="M50,78.5L50,78.5A2.15,3 90,0 1,47 76.35L47,63.65A2.15,3 90,0 1,50 61.5L50,61.5A2.15,3 90,0 1,53 63.65L53,76.35A2.15,3 90,0 1,50 78.5z"
      android:fillColor="#91979b"/>
  <path
      android:pathData="M33.248,73.057L33.248,73.057A2.15,3 126,0 1,32.085 69.554L39.55,59.28A2.15,3 126,0 1,43.24 59.304L43.24,59.304A2.15,3 126,0 1,44.404 62.806L36.939,73.081A2.15,3 126,0 1,33.248 73.057z"
      android:fillColor="#91979b"/>
  <path
      android:pathData="M22.895,58.807L22.895,58.807A3,2.15 72,0 1,24.013 55.289L36.091,51.365A3,2.15 72,0 1,39.063 53.554L39.063,53.554A3,2.15 72,0 1,37.945 57.071L25.867,60.996A3,2.15 72,0 1,22.895 58.807z"
      android:fillColor="#91979b"/>
  <path
      android:pathData="M22.895,41.193L22.895,41.193A3,2.15 108,0 1,25.867 39.004L37.945,42.929A3,2.15 108,0 1,39.063 46.446L39.063,46.446A3,2.15 108,0 1,36.091 48.635L24.013,44.711A3,2.15 108,0 1,22.895 41.193z"
      android:fillColor="#91979b"/>
  <path
      android:pathData="M33.248,26.943L33.248,26.943A2.15,3 54,0 1,36.939 26.919L44.404,37.194A2.15,3 54,0 1,43.24 40.696L43.24,40.696A2.15,3 54,0 1,39.55 40.72L32.085,30.446A2.15,3 54,0 1,33.248 26.943z"
      android:fillColor="#91979b"/>
</vector>

1 个答案:

答案 0 :(得分:0)

如果您使用AnimatedSvgView,则只需将这些路径添加到string-array中。