在文件夹drawable文件夹中创建xml文件
类似如下:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/nv1" android:duration="500" />
<item android:drawable="@drawable/nv2" android:duration="500" />
<item android:drawable="@drawable/nv3" android:duration="500" />
<item android:drawable="@drawable/nv4" android:duration="500" />
</animation-list>
在主要函数调用如下:
imageView.setBackgroundResource(R.drawable.anim_nv);
AnimationDrawable animationDrawable = (AnimationDrawable)imageView.getBackground();
animationDrawable.start();
本文介绍如何在Android项目的drawable文件夹中创建XML文件来定义动画列表,并展示了如何通过代码在Activity中调用并播放这些动画。具体步骤包括定义动画帧图片资源、设置动画播放间隔等。
3531

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



