Android Animation 帧动画监听结束的技巧
发布时间:2021-12-18 16:18:36 所属栏目:PHP教程 来源:互联网
导读:这个问题用中文搜了很久一直没有解决,今天尝试用英文在Google上搜了一下,打开第一个网页就把困扰的很久的问题解决了 问题描述:帧动画连续播放--Android 帧动画没有提供结束动作的监听方法,怎么实现播放完一个动画之后接着播放第二个动画呢? 正确方法1:
这个问题用中文搜了很久一直没有解决,今天尝试用英文在Google上搜了一下,打开第一个网页就把困扰的很久的问题解决了 问题描述:帧动画连续播放--Android 帧动画没有提供结束动作的监听方法,怎么实现播放完一个动画之后接着播放第二个动画呢? 正确方法1: public void mmswoon(){ imageView.setBackgroundResource(R.anim.mmswoon); AnimationDrawable animationDrawable = (AnimationDrawable)imageView.getBackground(); animationDrawable.start(); int duration = 0; for(int i=0;i<animationDrawable.getNumberOfFrames();i++){ duration += animationDrawable.getDuration(i); } Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { //此处调用第二个动画播放方法 } }, duration); } duration是第一个动画播放的总时间 PS :自己试过了,可以实现效果微笑 正确方法2: this.q_pic_view.setImageResource(0); this.q_pic_view.setBackgroundResource(R.drawable.animation_test); AnimationDrawable correct_animation = (AnimationDrawable) this.q_pic_view.getBackground(); correct_animation.start(); //here I tried to implement option C but it didn't work while(correct_animation.isRunning()){ try { Thread.sleep(20); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } 这个方法没有试过 ![]() (编辑:应用网_丽江站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |