diff options
| -rw-r--r-- | src/com/android/phone/common/animation/AnimUtils.java | 30 | ||||
| -rw-r--r-- | src/com/android/phone/common/dialpad/DialpadView.java | 2 |
2 files changed, 31 insertions, 1 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(); + } } diff --git a/src/com/android/phone/common/dialpad/DialpadView.java b/src/com/android/phone/common/dialpad/DialpadView.java index ef3edca..3cdc30e 100644 --- a/src/com/android/phone/common/dialpad/DialpadView.java +++ b/src/com/android/phone/common/dialpad/DialpadView.java @@ -131,7 +131,7 @@ public class DialpadView extends LinearLayout { lettersView = (TextView) dialpadKey.findViewById(R.id.dialpad_key_letters); final String numberString = resources.getString(numberIds[i]); final RippleDrawable rippleBackground = - (RippleDrawable) resources.getDrawable(R.drawable.btn_dialpad_key); + (RippleDrawable) getContext().getDrawable(R.drawable.btn_dialpad_key); if (mRippleColor != null) { rippleBackground.setColor(mRippleColor); } |
