summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/phone/common/animation/AnimUtils.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/com/android/phone/common/animation/AnimUtils.java b/src/com/android/phone/common/animation/AnimUtils.java
index 35ac107..3a5f679 100644
--- a/src/com/android/phone/common/animation/AnimUtils.java
+++ b/src/com/android/phone/common/animation/AnimUtils.java
@@ -18,11 +18,14 @@ package com.android.phone.common.animation;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
+import android.animation.ValueAnimator;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
+import java.lang.Float;
+
public class AnimUtils {
public static final int DEFAULT_DURATION = -1;
public static final Interpolator EASE_IN = new PathInterpolator(0.0f, 0.0f, 0.2f, 1.0f);
@@ -105,4 +108,31 @@ public class AnimUtils {
}
animator.start();
}
+
+ /**
+ * Animates a view to the new specified dimensions.
+ * @param view The view to change the dimensions of.
+ * @param newWidth The new width of the view.
+ * @param newHeight The new height of the view.
+ */
+ public static void changeDimensions(final View view, final int newWidth, final int newHeight) {
+ ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
+
+ final int oldWidth = view.getWidth();
+ final int oldHeight = view.getHeight();
+ final int deltaWidth = newWidth - oldWidth;
+ final int deltaHeight = newHeight - oldHeight;
+
+ animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animator) {
+ Float value = (Float) animator.getAnimatedValue();
+
+ view.getLayoutParams().width = (int) (value * deltaWidth + oldWidth);
+ view.getLayoutParams().height = (int) (value * deltaHeight + oldHeight);
+ view.requestLayout();
+ }
+ });
+ animator.start();
+ }
}