- 
      
- 
        Save girish3/71d845bc4a61623c1cfa to your computer and use it in GitHub Desktop. 
    Resize animation on Android
  
        
  
    
      This file contains hidden or 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 targetWidth; | |
| View view; | |
| public ResizeAnimation(View view, int targetWidth) { | |
| this.view = view; | |
| this.targetWidth = targetWidth; | |
| startWidth = view.getWidth(); | |
| } | |
| @Override | |
| protected void applyTransformation(float interpolatedTime, Transformation t) { | |
| int newWidth = (int) (startWidth + (targetWidth - startWidth) * interpolatedTime); | |
| view.getLayoutParams().width = 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; | |
| } | |
| } | 
  
    
      This file contains hidden or 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
    
  
  
    
  | ResizeAnimation resizeAnimation = new ResizeAnimation(view, targetSize); | |
| resizeAnimation.setDuration(600); | |
| view.startAnimation(resizeAnimation); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment