Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
类似于domino的Android动画_Android_Animation_Handler - Fatal编程技术网

类似于domino的Android动画

类似于domino的Android动画,android,animation,handler,Android,Animation,Handler,我想制作多米诺骨牌效果的动画。 但当我将动画xml和处理程序与for循环一起使用时,它会同时工作 如何制作domino效果动画,例如在第一个按钮(mon)启动100毫秒后为下一个按钮(tue)启动动画 这里是我的汉尔德方法 private void startAnimation(final ArrayList<View> vArr) { mon = (Button)findViewById(R.id.mon); tue = (Button)findViewById(R

我想制作多米诺骨牌效果的动画。 但当我将动画xml和处理程序与for循环一起使用时,它会同时工作

如何制作domino效果动画,例如在第一个按钮(mon)启动100毫秒后为下一个按钮(tue)启动动画

这里是我的汉尔德方法

private void startAnimation(final ArrayList<View> vArr)
{
    mon = (Button)findViewById(R.id.mon);
    tue = (Button)findViewById(R.id.tue);
    wed = (Button)findViewById(R.id.wed);
    thu = (Button)findViewById(R.id.thu);
    fri = (Button)findViewById(R.id.fri);
    sat = (Button)findViewById(R.id.sat);
    sun = (Button)findViewById(R.id.sun);

    final Button[] weekDayList = {mon, tue, wed, thu, fri, sat, sun};

    Handler handler = new Handler()
    {
        @Override
        public void handleMessage(Message msg)
        {
            super.handleMessage(msg);

            switch (msg.what)
            {
                case 3:
                    for (int i = 0; i < weekDayList.length; i++)
                        weekDayList[i].startAnimation(buttonDown);

                    sendEmptyMessageDelayed(4, 100);

                    break;

                case 4:

                    break;
            }
        }
    };

    handler.sendEmptyMessage(3);
}
private void startAnimation(最终数组列表vArr)
{
mon=(按钮)findviewbyd(R.id.mon);
tue=(按钮)findViewById(R.id.tue);
wed=(按钮)findViewById(R.id.wed);
thu=(按钮)findviewbyd(R.id.thu);
fri=(按钮)findViewById(R.id.fri);
sat=(按钮)findViewById(R.id.sat);
sun=(按钮)findviewbyd(R.id.sun);
最后按钮[]工作日列表={周一、周二、周三、周四、周五、周六、周日};
Handler=newhandler()
{
@凌驾
公共无效handleMessage(消息消息消息)
{
超级handleMessage(msg);
开关(msg.what)
{
案例3:
for(int i=0;i
这里是我的动画xml

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

<scale
    android:fromXScale="1.0"
    android:toXScale="1.0"
    android:fromYScale="1.0"
    android:toYScale="0.0"
    android:pivotX="50%"
    android:pivotY="100%"
    android:duration="500" />
</set>

设置为动画。使用onAnimationEnd()
开始下一个动画

您可以使用
ObjectAnimator
(从API 11开始)来执行此操作,并通过将动画全部添加到
AnimatorSet
,使动画按顺序播放

  public void dominoAnimations() {
    ObjectAnimator monAnimation = ObjectAnimator.ofFloat(mon, "scaleY", 0f);
    ObjectAnimator tueAnimation = ObjectAnimator.ofFloat(tue, "scaleY", 0f);
    ObjectAnimator wedAnimation = ObjectAnimator.ofFloat(wed, "scaleY", 0f);
    ObjectAnimator thuAnimation = ObjectAnimator.ofFloat(thu, "scaleY", 0f);
    ObjectAnimator friAnimation = ObjectAnimator.ofFloat(fri, "scaleY", 0f);
    ObjectAnimator satAnimation = ObjectAnimator.ofFloat(sat, "scaleY", 0f);
    ObjectAnimator sunAnimation = ObjectAnimator.ofFloat(sun, "scaleY", 0f);

    AnimatorSet dominoes = new AnimatorSet();
    dominoes.playSequentially(
      monAnimation, tueAnimation, wedAnimation,
      thuAnimation, friAnimation, satAnimation, sunAnimation
    );

    dominoes.setDuration(500);
    dominoes.start();
  }

但是,我想做的是在第一个动画工作时启动下一个动画。是否可以向ObjectAnimation添加几个选项?我需要让它从上到下消失