change Icon Animation - Android Animation

Android examples for Animation:Animation Creation

Description

change Icon Animation

Demo Code


//package com.java2s;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.os.Handler;

import android.view.animation.OvershootInterpolator;

import android.widget.TextView;

public class Main {
    public static final int DURATION_CHANGE_ICON_ANIM = 400;

    public static void changeIconAnim(final TextView iconTextView,
            final String finalText) {
        Handler handler = new Handler();
        AnimatorSet scaleDown = new AnimatorSet();
        scaleDown.playTogether(//from  w  w  w  .  j  a  v  a  2  s.  c om
                ObjectAnimator.ofFloat(iconTextView, "scaleX", 1, 0.4f, 1),
                ObjectAnimator.ofFloat(iconTextView, "scaleY", 1, 0.4f, 1));
        scaleDown.setDuration(DURATION_CHANGE_ICON_ANIM);
        scaleDown.setInterpolator(new OvershootInterpolator());
        scaleDown.start();

        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                iconTextView.setText(finalText);
            }
        }, DURATION_CHANGE_ICON_ANIM / 4);
    }
}

Related Tutorials