float And Fade Animation - Android Animation

Android examples for Animation:Fade Animation

Description

float And Fade Animation

Demo Code


//package com.java2s;

import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AlphaAnimation;

import android.view.animation.AnimationSet;

import android.view.animation.TranslateAnimation;

public class Main {
    public static AnimationSet floatAndFadeAnimation(int x, int startY,
            int endY, int repeatCount, long startOffset, long floatDuration) {
        AnimationSet floatAndFade = new AnimationSet(false);
        TranslateAnimation floatAnim = new TranslateAnimation(x, x, startY,
                endY);/*from   ww  w  .  j a v a2s  . c o m*/
        floatAnim.setInterpolator(new AccelerateDecelerateInterpolator());
        floatAnim.setFillAfter(true);
        AlphaAnimation fadeAnim = new AlphaAnimation(1f, 0f);
        fadeAnim.setFillAfter(true);
        floatAndFade.addAnimation(floatAnim);
        floatAndFade.addAnimation(fadeAnim);
        floatAndFade.setDuration(floatDuration);
        floatAndFade.setStartOffset(startOffset);
        floatAndFade.setRepeatCount(repeatCount);
        return floatAndFade;
    }
}

Related Tutorials