欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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();