start Send File Animation - Android Animation

Android examples for Animation:Animation Creation

Description

start Send File Animation

Demo Code


//package com.java2s;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

public class Main {

    public static void startSendFileAnimation(final View startView,
            final View endView, int startLocationX, int startLocationY,
            int endLocationX, int endLocationY) {
        int endX = endLocationX + endView.getMeasuredWidth() / 2;
        int endY = endLocationY + endView.getMeasuredHeight() / 2;

        int startX = startLocationX + startView.getWidth() / 2;
        int startY = startLocationY + startView.getHeight() / 2;
        int moveX = endX - startX;
        int moveY = endY - startY;

        AnimationSet animationSet = new AnimationSet(false);
        Animation translateAnimation = new TranslateAnimation(0, moveX, 0,
                moveY);//from  w w w.  j  av a2 s.co m
        Animation rotateAnimation = new RotateAnimation(0, 359,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        Animation scaleAnimation = new ScaleAnimation(1.0f, 0.3f, 1.0f,
                0.3f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        animationSet.addAnimation(rotateAnimation);
        animationSet.addAnimation(scaleAnimation);
        animationSet.addAnimation(translateAnimation);
        animationSet.setDuration(600);
        animationSet.setFillAfter(false);
        animationSet
                .setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {

                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        startView.setVisibility(View.GONE);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {

                    }
                });
        startView.startAnimation(animationSet);

    }
}

Related Tutorials