如何从assets文件夹中的图像创建一个Android逐帧动画?

时间:2013-06-23 10:59:19

标签: android animation assets

我是android的初学者,我想创建一个逐帧动画,将其图像放在assets文件夹中。以前我创建了一个简单的动画,图像放在res / drawable文件夹中。我还在该文件夹中放置了一个gyro_animation.xml文件。在这个示例中,我在我的活动中创建了一个动画,如下所示:

    ImageView gyroView = (ImageView) findViewById(R.id.gyro);
    gyroView.setBackgroundResource(R.drawable.gyro_animation));
    final AnimationDrawable gyroAnimation = (AnimationDrawable) gyroView.getBackground();

现在用于创建动画,其图像位于资源文件夹中,我该怎么办?

提前感谢。

2 个答案:

答案 0 :(得分:0)

在资源文件夹中创建一个动画列表drawable,并将其设置为ImageView的背景。您可以看到详细的表达式here

答案 1 :(得分:0)

直接使用AnimationDrawable API

您必须在资源文件夹make BitmapDrawables of of them like here中加载图片,然后在new AnimationDrawable()上使用AnimationDrawable.addFrame

相关问题