Created
July 28, 2014 09:37
-
-
Save sbelloz/9a2080df8eb17a3f9010 to your computer and use it in GitHub Desktop.
A class that produce an animation when resizing a view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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