您可以像创建一系列图像一样创建动画,然后使用AnimationDrawable类将其制作为动画。让我告诉你一个例子:
ImageView my_image = (ImageView) findViewById(R.id.my_animation);
AnimationDrawable animation = new AnimationDrawable();
// We need to add each image to our final animation setting time interval between them
animation.addFrame(getResources().getDrawable(R.drawable.img_1), 200);
animation.addFrame(getResources().getDrawable(R.drawable.img_2), 200);
animation.addFrame(getResources().getDrawable(R.drawable.img_3), 200);
animation.setOneShot(false);
my_image.setBackgroundDrawable(animation); // Set as background to see it
animation.start(); // Start playing the animation
其中:
my_animation
:您的ImageView到您的愿望布局。
img_1
,img_2
,img_3
:即化合物动画图像(你应该 创建并保存为res/drawable
文件夹)。
我希望它可以帮助你和借鉴的方式通过自己:)做
PS:这应该是插入所需的活性的方法(例如,为onCreate
表现出来当用户启动时)。