undo Focus On Animation - Android Animation

Android examples for Animation:Animation Creation

Description

undo Focus On Animation

Demo Code


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

import android.view.MotionEvent;
import android.view.View;

import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;

public class Main {
    private static final int ANIMATE_DURATION = 700;
    private static final Interpolator ANIMATE_INTERPOLATOR = new AccelerateDecelerateInterpolator();

    public static void undoFocusOn(final View v) {

        v.setOnTouchListener(new View.OnTouchListener() {
            @Override/*  w  ww  .j  a  v  a2s  .c  o m*/
            public boolean onTouch(View view, MotionEvent motionEvent) {
                return false;
            }
        });

        v.setLayerType(View.LAYER_TYPE_HARDWARE, null);

        v.animate().translationY(0).setDuration(ANIMATE_DURATION)
                .setInterpolator(ANIMATE_INTERPOLATOR)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        v.setLayerType(View.LAYER_TYPE_NONE, null);
                        super.onAnimationEnd(animation);
                    }
                }).start();
    }
}

Related Tutorials