循环动画可绘制 [英] Loop animation drawable

查看:68
本文介绍了循环动画可绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为某些png设置动画,并且我会循环播放动画.这是我的代码:

I'm trying to animate some png and i would loop the animation. This is my code:

wave.setBackgroundResource(R.drawable.wave_animation);
                frameAnimation = (AnimationDrawable)wave.getBackground();
                frameAnimation.setCallback(wave);
                frameAnimation.setVisible(true, true);
                frameAnimation.start();

,这里是带有png的xml

and here the xml with the png

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"  android:oneshot="true">
    <item android:drawable="@drawable/wave_01" android:duration="200" />
    <item android:drawable="@drawable/wave_02" android:duration="200" />
    <item android:drawable="@drawable/wave_03" android:duration="200" />
    <item android:drawable="@drawable/wave_04" android:duration="200" />
</animation-list>

我还添加了android:oneshot = false,但不起作用.

I added also the android:oneshot=false but doesn't work.

推荐答案

只需将android:oneshot="false"更改为这样

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"  android:oneshot="false">
    <item android:drawable="@drawable/wave_01" android:duration="200" />
    <item android:drawable="@drawable/wave_02" android:duration="200" />
    <item android:drawable="@drawable/wave_03" android:duration="200" />
    <item android:drawable="@drawable/wave_04" android:duration="200" />
</animation-list>

这篇关于循环动画可绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆