resizes the width of a view - Android User Interface

Android examples for User Interface:View Size

Description

resizes the width of a view

Demo Code


import android.os.Handler;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;

public class Main{
    private static final int ANIMATION_SPEED = 100;
    public static void resizeWidth(View view, float oldWidth, float newWidth) {
        resizeWidth(view, oldWidth, newWidth, ANIMATION_SPEED);
    }//  w  w  w. j a  v a  2s  .c  o m
    /**
     * resizes the width of a view
     * @param view
     * @param oldWidth
     * @param newWidth
     */
    public static void resizeWidth(View view, float oldWidth,
            float newWidth, int duration) {
        final Animation resizeX = new ResizeAnimation(view, oldWidth,
                view.getHeight(), newWidth, view.getHeight());
        resizeX.setDuration(duration);
        view.setAnimation(resizeX);
    }
}

Related Tutorials