Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.view.animation.AnimationSet;

import android.view.animation.OvershootInterpolator;

import android.view.animation.TranslateAnimation;

public class Main {
    public static AnimationSet ShuffleAnimation(int deltaX, int deltaY) {

        TranslateAnimation shake_1 = new TranslateAnimation(0, deltaX, 0, deltaY);
        shake_1.setDuration(400);
        shake_1.setStartOffset(0);
        shake_1.setFillAfter(true);
        TranslateAnimation shake_2 = new TranslateAnimation(0, -deltaX, 0, -deltaY);
        shake_2.setDuration(400);
        shake_2.setStartOffset(400);
        shake_2.setFillAfter(true);
        AnimationSet ShakeIt = new AnimationSet(true);
        ShakeIt.addAnimation(shake_1);
        ShakeIt.addAnimation(shake_2);
        ShakeIt.setInterpolator(new OvershootInterpolator());

        return ShakeIt;
    }
}