Animator to animate Y scale of the view with ObjectAnimator. - Android Animation

Android examples for Animation:Scale Animation

Description

Animator to animate Y scale of the view with ObjectAnimator.

Demo Code


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

import android.support.annotation.NonNull;
import android.view.View;

public class Main {
    /**/* w  ww  .  j  a  va  2  s  . c o  m*/
     * Animator to animate Y scale of the view. X scale is constant
     *
     * @param view View to be animated
     * @param pivotX x coordinate of the pivot
     * @param pivotY y coordinate of the pivot
     * @param fromScale initial scale
     * @param toScale final scale
     * @param duration animation duration in milliseconds
     * @return Animator Object
     */
    @NonNull
    public static Animator scaleY(@NonNull View view, int pivotX,
            int pivotY, float fromScale, float toScale, int duration) {
        view.setPivotX(pivotX);
        view.setPivotY(pivotY);
        Animator animator = ObjectAnimator.ofFloat(view, "scaleY",
                fromScale, toScale);
        animator.setDuration(duration);
        return animator;
    }
}

Related Tutorials