2013-10-09 34 views
1

我存储在RES /动画/ draw_circle_violet.xml动画列表动画列表:ANDROID - 如何清除应用于ImageView的

<?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> 

这个动画应用到的ImageView:

mImageView.setBackgroundResource(R.anim.draw_circle_violet); 
     AnimationDrawable frameAnimation = (AnimationDrawable) mImageView 
       .getBackground(); 
     frameAnimation.start(); 

我点击一个按钮来清除应用到这个ImageView的动画:

 mImageView.clearAnimation(); 

但动画不能删除。另一种方式,我试试这个:

 mImageView.setAnimation(null); 

但不成功。

Plz help。


更新:我已经试过

frameAnimation.stop(); 

但仍动画应用到ImageView的。任何理想? 这是我source code

回答

0

试试这个:

frameAnimation.stop(); 

希望这有助于:)

+0

我试过这个,但动画仍然适用于ImageView。任何理想?感谢您的回复。 –

+0

我已更新源代码。 Plz的帮助。 –

0

这是一个肮脏的方式,但工程:

setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

让我知道如果这并没有解决你的问题。

+0

没有方法将setBackground()应用于ImageView。只有3种方法:应用于ImageView的setBackgroundColor(int color),setBackgroundDrawable(Drawable background),setBackgroundResource(int resid)。 Plz检查。感谢您的回复。 –

+0

我的糟糕的'setBackground'方法用于API 16.您可以使用'setBackgroundDrawable' – 4gus71n