我有一个xml框架动画,我希望它只运行一次。但它一直在无限地运行..。即使我用了isOneShot()
这是我的密码
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
import de.vrallev.tutorial.dialer.R;
public class testanim extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.animtest);
ImageView iv = (ImageView) findViewById(R.id.imageView1);
iv.setImageBitmap(null);
iv.setBackgroundResource(R.anim.animation);
final AnimationDrawable mailAnimation = (AnimationDrawable) iv
.getBackground();
mailAnimation.isOneShot();
mailAnimation.start();发布于 2014-09-22 19:41:42
我猜你误解了isOneShot()的方法。此方法返回动画是否只播放一次。如果要将动画设置为只运行一次,则必须调用方法setOneShot (booleanValue)。
因此,在您的例子中,编写如下所示:mailAnimation.setOneShot(true)
也请参阅有关此主题的文档(点击)。
https://stackoverflow.com/questions/25980993
复制相似问题