slide View To Bottom Of Screen - Android User Interface

Android examples for User Interface:View Slide

Description

slide View To Bottom Of Screen

Demo Code


//package com.java2s;
import android.animation.Animator;

import android.animation.ValueAnimator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

public class Main {
    public static void slideToBottomOfScreen(@NonNull final View v,
            int screenHeight, int slideTime,
            @Nullable Animator.AnimatorListener listener) {
        ValueAnimator a = ValueAnimator.ofFloat(0f,
                screenHeight - v.getBottom());
        a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override/*  w  w w.j a  v  a  2 s.c  o  m*/
            public void onAnimationUpdate(@NonNull ValueAnimator animation) {
                v.setTranslationY((Float) animation.getAnimatedValue());
            }
        });
        a.setDuration(slideTime);
        if (listener != null)
            a.addListener(listener);
        a.start();
    }
}

Related Tutorials