remove Loading Animation End - Android Animation

Android examples for Animation:Move Animation

Description

remove Loading Animation End

Demo Code


//package com.java2s;

import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;

import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

public class Main {
    private int randomNumberAnimation = 0;

    public static void removeLoadingAnimationEnd(final View view) {

        view.setVisibility(View.VISIBLE);
        view.clearAnimation();// ww  w .j  a  va2s  .c  om

        AnimationSet set = new AnimationSet(true);
        set.setFillAfter(true);
        set.setDuration(700);

        ScaleAnimation scaleAnimation = new ScaleAnimation(1f, .0f, 1f,
                .0f, Animation.RELATIVE_TO_SELF, (float) 0.5,
                Animation.RELATIVE_TO_SELF, (float) 0.5);

        set.addAnimation(scaleAnimation);

        view.startAnimation(set);

        set.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                // TODO Auto-generated method stub

                view.setVisibility(View.INVISIBLE);
            }
        });
    }

    public void startAnimation(final View imageView,
            float translateFromDeltaX, float translatetodeltaX,
            float rotateFromDegree, float rotateToDegree, final int i) {

        imageView.setVisibility(View.VISIBLE);

        AnimationSet set = new AnimationSet(true);
        set.setFillAfter(true);
        set.setDuration(500);

        TranslateAnimation transX = new TranslateAnimation(
                translateFromDeltaX, translatetodeltaX, 0, 0);
        transX.setStartOffset(0);
        transX.setFillAfter(true);

        RotateAnimation an = new RotateAnimation(rotateFromDegree,
                rotateToDegree, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);

        an.setRepeatCount(0);
        an.setFillAfter(false);

        ScaleAnimation scaleAnimation = new ScaleAnimation(.0f, 1f, .0f,
                1f, Animation.RELATIVE_TO_SELF, (float) 0.5,
                Animation.RELATIVE_TO_SELF, (float) 0.5);

        switch (randomNumberAnimation) {
        case 0:

            set.addAnimation(an);
            set.addAnimation(transX);
            set.addAnimation(scaleAnimation);
            break;

        case 1:
            set.addAnimation(scaleAnimation);
            break;
        }

        imageView.startAnimation(set);

        set.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationEnd(Animation animation) {
            }
        });

    }
}

Related Tutorials