问题描述:

I have an animation-list stored in res/anim/draw_circle_violet.xml :

<?xml version="1.0" encoding="utf-8"?>

<animation-list android:oneshot="true"

xmlns:android="http://schemas.android.com/apk/res/android">

<item android:duration="10" android:drawable="@drawable/plainimg"/>

<item android:duration="10" android:drawable="@drawable/circlev1"/>

<item android:duration="10" android:drawable="@drawable/circlev2"/>

<item android:duration="10" android:drawable="@drawable/circlev3"/>

<item android:duration="10" android:drawable="@drawable/circlev4"/>

<item android:duration="10" android:drawable="@drawable/circlev5"/>

<item android:duration="10" android:drawable="@drawable/circlev6"/>

<item android:duration="10" android:drawable="@drawable/circlev7"/>

<item android:duration="10" android:drawable="@drawable/circlev8"/>

</animation-list>

This animation is applied to an ImageView :

mImageView.setBackgroundResource(R.anim.draw_circle_violet);

AnimationDrawable frameAnimation = (AnimationDrawable) mImageView

.getBackground();

frameAnimation.start();

I click a button to clear animation applied to this ImageView :

 mImageView.clearAnimation();

but animation can't be removed. ANother way, I try this :

 mImageView.setAnimation(null);

but not successfull.

Plz help.


Update : I have tried

 frameAnimation.stop();

but animation still applied to ImageView. Any ideal ?

Here is my source code

网友答案:

try this:

frameAnimation.stop();

Hope this helps :)

网友答案:

This is a dirty way, but works:

setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

Let me know if this didn't solve your issue.

相关阅读:
Top