start Softly Slide Up - Android Animation

Android examples for Animation:Slide Animation

Description

start Softly Slide Up

Demo Code


//package com.java2s;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.view.View;
import android.view.animation.DecelerateInterpolator;

public class Main {
    public static void startSoftlySlideUp(final View view,
            final int duration) {
        Context context = view.getContext();
        final int translateY = context.getResources().getDisplayMetrics().heightPixels;
        view.animate().translationY(translateY).setDuration(0)
                .setListener(new AnimatorListenerAdapter() {
                    @Override//from  w  ww .  j  a  va2 s  .  c  om
                    public void onAnimationEnd(Animator animation) {
                        view.animate()
                                .translationY(0)
                                .setStartDelay(duration)
                                .setInterpolator(
                                        new DecelerateInterpolator())
                                .setDuration(duration).setListener(null);
                    }
                });
    }
}

Related Tutorials