Android 帧动画,加载动画,AnimationDrawable
程序员文章站
2022-03-16 16:13:15
...
1、创建drawable文件ring_animation.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
>
<item android:drawable="@mipmap/windmill_1"
android:duration="10">
</item>
<item android:drawable="@mipmap/windmill_2"
android:duration="10">
</item>
<item android:drawable="@mipmap/windmill_3"
android:duration="10">
</item>
<item android:drawable="@mipmap/windmill_4"
android:duration="10">
</item>
<item android:drawable="@mipmap/windmill_5"
android:duration="10">
</item>
<item android:drawable="@mipmap/windmill_6"
android:duration="10">
</item>
<item android:drawable="@mipmap/windmill_7"
android:duration="10">
</item>
</animation-list>
2、imageview启动帧动画
ImageView iv = (ImageView)findViewById(R.id.iv);
iv.setImageResource(R.drawable.ring_animation);
AnimationDrawable animationDrawable = (AnimationDrawable) iv.getDrawable();
animationDrawable.start();