Animates a coming from left to right of a specified view - Android User Interface

Android examples for User Interface:View Animation

Description

Animates a coming from left to right of a specified view

Demo Code


//package com.java2s;

import android.view.View;
import android.view.animation.AccelerateInterpolator;

import android.view.animation.Animation;

import android.view.animation.ScaleAnimation;

public class Main {
    /**/*from  w w  w.j a  v a 2  s  . c om*/
     * Animates a coming from left to right of a specified view
     * 
     * @param v
     *            the view to animate.
     */
    public static void animateTopToDown(View v) {

        v.setVisibility(View.VISIBLE);

        ScaleAnimation animation = new ScaleAnimation(1, 1, 0, 1,
                Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_SELF,
                Animation.RELATIVE_TO_SELF, 0);
        animation.setFillAfter(true);
        animation.setDuration(500);
        animation.setInterpolator(new AccelerateInterpolator());

        v.startAnimation(animation);
    }
}

Related Tutorials