translate effect Animation - Android Animation

Android examples for Animation:Translate Animation

Description

translate effect Animation

Demo Code


//package com.java2s;
import android.view.View;

import android.view.animation.CycleInterpolator;

import android.view.animation.TranslateAnimation;

public class Main {

    public static void translate(View view, float fromXDelta,
            float toXDelta, float fromYDelta, float toYDelta,
            long durationMillis, float cycles) {
        TranslateAnimation translateAnimation = new TranslateAnimation(
                fromXDelta, toXDelta, fromYDelta, toYDelta);
        translateAnimation.setDuration(durationMillis);
        if (cycles > 0.0) {
            translateAnimation/*  w w  w  .  j  a va 2  s. co m*/
                    .setInterpolator(new CycleInterpolator(cycles));
        }
        view.startAnimation(translateAnimation);
    }
}

Related Tutorials