Java tutorial
//package com.java2s; //License from project: Open Source License import android.support.v4.app.FragmentActivity; import android.util.DisplayMetrics; import android.view.View; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationSet; import android.view.animation.LinearInterpolator; import android.view.animation.ScaleAnimation; import android.view.animation.TranslateAnimation; public class Main { public static void shrinkToLeft(FragmentActivity activity, View view, AnimationListener listener) { DisplayMetrics displaymetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int screenHeight = displaymetrics.heightPixels; int screenWidth = displaymetrics.widthPixels; AnimationSet animation = new AnimationSet(true); float pivotX = view.getWidth() / 2; float pivotY = view.getHeight() / 2; ScaleAnimation anim = new ScaleAnimation(1f, 0.8f, 1f, 0.8f, pivotX, pivotY); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(200); anim.setStartOffset(200); //anim.setFillAfter(true); animation.addAnimation(anim); TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) -(screenWidth - view.getWidth()), 0.0f, 0.0f); anim.setInterpolator(new LinearInterpolator()); animTrans.setDuration(400); //animTrans.setStartOffset(300); animation.addAnimation(animTrans); if (listener != null) animation.setAnimationListener(listener); view.startAnimation(animation); } }