make Submit Move ObjectAnimator - Android android.animation

Android examples for android.animation:ObjectAnimator

Description

make Submit Move ObjectAnimator

Demo Code


//package com.java2s;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;

public class Main {

    public static void makeSubmitMove(View v) {
        ObjectAnimator animX1 = ObjectAnimator.ofFloat(v, "translationX",
                0f, -400f);//from   w  w w.j  av  a  2  s.  c  om
        ObjectAnimator animY1 = ObjectAnimator.ofFloat(v, "translationY",
                0f, 400f);
        ObjectAnimator animX2 = ObjectAnimator.ofFloat(v, "translationX",
                -400f, 400f);
        ObjectAnimator animX3 = ObjectAnimator.ofFloat(v, "translationX",
                400f, 0f);
        ObjectAnimator animY3 = ObjectAnimator.ofFloat(v, "translationY",
                400f, 0f);
        AnimatorSet set1 = new AnimatorSet();
        set1.playTogether(animX1, animY1);
        AnimatorSet set3 = new AnimatorSet();
        set3.playTogether(animX3, animY3);
        set1.setDuration(300);
        animX2.setDuration(300);
        set3.setDuration(300);
        AnimatorSet tSet = new AnimatorSet();
        tSet.playSequentially(set1, animX2, set3);
        ObjectAnimator rAnim = ObjectAnimator.ofFloat(v, "rotation", 0f,
                3600f);
        rAnim.setDuration(900);
        AnimatorSet set = new AnimatorSet();
        set.play(tSet).with(rAnim);
        set.start();
    }
}

Related Tutorials