在Andrio的中,可以使用多幅图片实现动画效果。
首先定义一个以 <animation-list>为根节点的xml文件,命名为 anim.xml 放在 res/drawable/目录下。
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/image1" android:duration="200" />
<item android:drawable="@drawable/image2" android:duration="200" />
<item android:drawable="@drawable/image3" android:duration="200" />
</animation-list>
ImageView image = (ImageView) findViewById(R.id.rocket_image);
image.setBackgroundResource(R.drawable.rocket_thrust);
AnimationDrawable animation = (AnimationDrawable) image.getBackground(); 最后,在需要的时候启动动画即可。
animation.start();
本文介绍如何在Andrio中使用多幅图片实现动画效果。通过创建一个包含不同帧的XML文件并将其应用于ImageView,可以轻松地制作动画。文章还提供了启动动画的具体步骤。

1100

被折叠的 条评论
为什么被折叠?



