Skip to content

Instantly share code, notes, and snippets.

@sbelloz
Created July 28, 2014 09:37
Show Gist options
  • Save sbelloz/9a2080df8eb17a3f9010 to your computer and use it in GitHub Desktop.
Save sbelloz/9a2080df8eb17a3f9010 to your computer and use it in GitHub Desktop.
A class that produce an animation when resizing a view
public class ResizeAnimation extends Animation {
// final int startWidth;
final int startHeight;
final int targetHeight;
// final int targetWidth;
View view;
public ResizeAnimation(View view, int targetWidth) {
this.view = view;
// this.targetWidth = targetWidth;
// startWidth = view.getWidth();
startHeight = view.getHeight();
this.targetHeight = targetWidth;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
// int newWidth = (int) (startWidth + (targetWidth - startWidth) * interpolatedTime);
// view.getLayoutParams().width = newWidth;
int newWidth = (int) (startHeight + (targetHeight - startHeight) * interpolatedTime);
view.getLayoutParams().height = newWidth;
view.requestLayout();
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
@Override
public boolean willChangeBounds() {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment