安卓动画 animation-list START之后不能重新设置setImageResource否则动画将重新初始化,需要重新调用start

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
    <item
        android:drawable="@drawable/chatfrom_voice_playing_f3"
        android:duration="200" />
    <item
        android:drawable="@drawable/chatfrom_voice_playing_f1"
        android:duration="200" />
    <item
        android:drawable="@drawable/chatfrom_voice_playing_f2"
        android:duration="200" />
    <item
        android:drawable="@drawable/chatfrom_voice_playing_f1"
        android:duration="200" />
    <item
        android:drawable="@drawable/chatfrom_voice_playing_f3"
        android:duration="200" />
</animation-list>
//必须把一下两行设置去掉
//        holder.fromImgContent.setImageResource(R.drawable.voice_from_icon);
//        holder.toImgContent.setImageResource(R.drawable.voice_to_icon);
        if(!chatInfo.getAudioMessage().isAnimation()) {
            ((AnimationDrawable) holder.fromImgContent.getDrawable()).setOneShot(true);
            ((AnimationDrawable) holder.toImgContent.getDrawable()).setOneShot(true);

猜你喜欢

转载自blog.csdn.net/jasonhongcn/article/details/87877876