34 帧动画

it2022-05-05  183

在res/anim目录下新建文件:

<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"><!--android:oneshot="true" 只播放一次 false循环播放--> <item android:drawable="@drawable/01" android:duration="50"/> <item android:drawable="@drawable/02" android:duration="50"/> <item android:drawable="@drawable/03" android:duration="50"/> <item android:drawable="@drawable/04" android:duration="50"/> <item android:drawable="@drawable/05" android:duration="50"/> </animation-list>

在xml布局文件中给imageview的background设置这个xml

 

在代码文件中:

AnimationDrawable animation = (AnimationDrawable)iamgeView.getBackground();

帧动画需要手动启动和停止:

animation.start();

animation.stop();

转载于:https://www.cnblogs.com/YyuTtian/p/5440781.html


最新回复(0)