如何启动的第一个动画列表结束后第二个动画列表 [英] how to start a second animation-list after the end of first animation-list

查看:131
本文介绍了如何启动的第一个动画列表结束后第二个动画列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要开始的第一个动画列表结束后第二个动画列表
第一个动画列表是(list_first):

i want to start a second animation-list after the end of first animation-list first animation-list is(list_first):

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

<item
android:drawable="@drawable/f11"
android:duration="500"/>

<item
android:drawable="@drawable/delay"
android:duration="1000"/>

<item
android:drawable="@drawable/f12"
android:duration="500"/>

<item
android:drawable="@drawable/delay"
android:duration="1000"/>

</animation-list>

第二个动画列表是(list_second):

Second animation-list is(list_second):

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

<item
android:drawable="@drawable/s21"
android:duration="500"/>

<item
android:drawable="@drawable/delay"
android:duration="1000"/>

<item
android:drawable="@drawable/s22"
android:duration="500"/>

<item
android:drawable="@drawable/delay"
android:duration="1000"/>

</animation-list>

现在如何在第一个列表的末尾开始第二次动画列表?

now how to start the second animation list at the end of first list?

ImageView img1;
TextView t1;

AnimationDrawable splashanimation;


@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
 super.onCreate(savedInstanceState);

    setContentView(R.layout.anim_layout);

    img1= (ImageView)findViewById(R.id.anim_imgview);
    img1.setBackgroundResource(R.drawable.list_first);
    splashanimation = (AnimationDrawable)img1.getBackground();
    splashanimation.start();

现在在这里我没有得到什么做的?如何开始第一次list..please年底建议

Now over here i am not getting what to do to ? how to start the second animation list on the end of first list..please suggest

推荐答案

试试这个:

splashanimation = (AnimationDrawable)img1.getBackground();
splashanimation.start();

Handler handler = new Handler();
handler.postDelayed(new Runnable() {
                       public void run() {
                            //start your 2nd animation
                            //secondAnimation.start();
                       }
                    }, delay);//delay = the duration of your first animation, i think its 3000 in your case

或者你可以在一个结合2 XML动画:

Or you can combine the 2 xml animation in one:

combine_anim.xml 文件

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

<item
android:drawable="@drawable/f11"
android:duration="500"/>

<item
android:drawable="@drawable/delay"
android:duration="1000"/>

<item
android:drawable="@drawable/f12"
android:duration="500"/>

<item
android:drawable="@drawable/delay"
android:duration="1000"/>

<item
android:drawable="@drawable/s21"
android:duration="500"/>

<item
android:drawable="@drawable/delay"
android:duration="1000"/>

<item
android:drawable="@drawable/s22"
android:duration="500"/>

<item
android:drawable="@drawable/delay"
android:duration="1000"/>

</animation-list>

和使用 combine_anim.xml 作为背景,而不是 list_first.xml

And you use combine_anim.xml as background instead of list_first.xml

这篇关于如何启动的第一个动画列表结束后第二个动画列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆