Skip to content

Instantly share code, notes, and snippets.

@umetsu
Last active August 29, 2015 14:28
Show Gist options
  • Save umetsu/d63e4db01fbf3e2a3733 to your computer and use it in GitHub Desktop.
Save umetsu/d63e4db01fbf3e2a3733 to your computer and use it in GitHub Desktop.
package net.prunusmume.sample;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class WidthAnimation extends Animation {
private final View mTargetView;
private final int mStartWidth;
private final int mTargetWidth;
public WidthAnimation(final View targetView, final int startWidth, final int targetWidth) {
mTargetView = targetView;
mStartWidth = startWidth;
mTargetWidth = targetWidth;
}
@Override
protected void applyTransformation(final float interpolatedTime, final Transformation t) {
mTargetView.getLayoutParams().width = (int) (mStartWidth + (mTargetWidth - mStartWidth) * interpolatedTime);
mTargetView.requestLayout();
}
@Override
public boolean willChangeBounds() {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment