Android 帧动画(FrameAnimation)的使用

    xiaoxiao2025-08-04  15

    帧动画(FrameAnimation)

    说明

    贞动画按照名字理解就是动画一帧一帧的播放,这个动画相对来说也是很简单。

    首先在xml中定义:

    <?xml version="1.0" encoding="utf-8"?><!-- 根标签为animation-list,其中oneshot代表着是否只展示一遍,设置为false会不停的循环播放动画 根标签下,通过item标签对动画中的每一个图片进行声明 android:duration 表示展示所用的该图片的时间长度 --> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@mipmap/a" android:duration="300" /> <item android:drawable="@mipmap/b" android:duration="300" /> <item android:drawable="@mipmap/c" android:duration="300" /> </animation-list> 然后在代码中开始动画就可以了。

    imageview.setBackgroundResource(R.drawable.iv_bg); 

    AnimationDrawable animationDrawable = (AnimationDrawable) imageview.getBackground();

     animationDrawable.start();

    转载请注明原文地址: https://ju.6miu.com/read-1301379.html
    最新回复(0)