Android 使用JSON和XML设置图像动画

Android 使用JSON和XML设置图像动画,android,json,xml,animation,video-processing,Android,Json,Xml,Animation,Video Processing,我浏览了很多关于如何使用gn.json和.xml文件执行动画的内容,这些文件包含一些值和因子,可以使用一些图像创建动画 因为我是新来的,所以我不明白如何才能做到这一点。 下面是一些必需的项目,比如带有图像的.json和.xml文件 这里是.json文件 { "effectList": [ { "duration": 6000, "end_time": 99999999, "path": "01/", // folder name of Device

我浏览了很多关于如何使用gn.json和.xml文件执行动画的内容,这些文件包含一些值和因子,可以使用一些图像创建动画

因为我是新来的,所以我不明白如何才能做到这一点。 下面是一些必需的项目,比如带有图像的.json和.xml文件

这里是
.json
文件

{
  "effectList": [
    {
      "duration": 6000,
      "end_time": 99999999,
      "path": "01/", // folder name of Device
      "start_time": 0,
      "type": 1
    },
    {
      "duration": 3000,
      "end_time": 0,
      "path": "02/",
      "start_time": 0,
      "type": 2
    },
    {
      "duration": 3000,
      "end_time": 0,
      "path": "03/",
      "start_time": 0,
      "type": 2
    }
  ],
  "backgroundColor": 3,
  "moveType": 2,
  "musicConfig": "{\"zh\":\"abc\",\"path\":\"music/Seductive Blues.m4a\",\"en\":\"Seductive Blues\"}",
  "clip_duration": [
    0,
    0
  ],
  "isTransRand": 0
}

这是我想要创建的输出

这里有两个在json和xml中使用的图像

命名为1.jpg和2.jpg


任何小的帮助都是可以考虑的,并提前通知。谢谢

要使用
xml
设置图像动画,您可以使用
帧动画
(又称
可绘制动画
)。在本例中,将以XML定义帧动画,将其放置在
res/drawable/
文件夹中,并将其设置为视图对象的背景。然后,调用
start()
运行动画

// Load the ImageView that will host the animation and
 // set its background to our AnimationDrawable XML resource.
 ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
 img.setBackgroundResource(R.drawable.spin_animation); 

// Get the background, which has been compiled to an AnimationDrawable object.
 AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();

 // Start the animation (looped playback by default).
 frameAnimation.start();
XML中定义的
AnimationDrawable
由单个


json
而言,我认为只使用json来制作图像动画。

谢谢@Abhi,我已经看过这个乐蒂动画了。但我不明白如何在我的应用程序中使用它。你能让我帮你吗?乐天动画通过向后效提供json数据来制作图像动画。Lottie是Adobe After Effects中使用的插件。谷歌上有几篇关于如何将乐天与Android集成的教程。看见你可以自己用谷歌搜索。你的问题有答案吗?
// Load the ImageView that will host the animation and
 // set its background to our AnimationDrawable XML resource.
 ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
 img.setBackgroundResource(R.drawable.spin_animation); 

// Get the background, which has been compiled to an AnimationDrawable object.
 AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();

 // Start the animation (looped playback by default).
 frameAnimation.start();