Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import android.view.animation.TranslateAnimation;

public class Main {
    /**
     *    move the background view(translate animation).
     * 
     * @param view
     *          the view will be moved
     * @param durationMillis
     *          translate animation duration
     * @param fromX
     *          from X coordinate
     * @param toX
     *          to X coordinate
     * @param fromY
     *          from Y coordinate
     * @param toY
     *          to Y coordinate
     */
    public static void translateFromBelow(final Context context, final View view, final long durationMillis,
            boolean fillAfter, float fromX, float toX, final float fromY, final float toY) {
        TranslateAnimation translateAnimation = new TranslateAnimation(fromX, toX, fromY, toY + 5);
        //      TranslateAnimation translateAnimation = new TranslateAnimation(fromX, toX, fromY, toY-21);
        translateAnimation.setDuration(durationMillis);
        translateAnimation.setFillAfter(fillAfter);//this animation performed will persist when it is finished
        view.startAnimation(translateAnimation);
        translateAnimation.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                //            TranslateAnimation shakeAnimation = new TranslateAnimation(0, 0, toY-21, toY+5);
                //            shakeAnimation.setInterpolator(new BounceInterpolator());
                //            shakeAnimation.setDuration(durationMillis); //500
                //            shakeAnimation.setFillAfter(true);
                //            view.startAnimation(shakeAnimation);
            }
        });
    }
}