I want to click a button and have certain View containers change size smoothly/transitionally. Can this be done in Android?
            Asked
            
        
        
            Active
            
        
            Viewed 208 times
        
    1
            
            
        - 
                    you should google it mate! – Atiq Apr 19 '16 at 18:18
- 
                    I did! I couldn't find what I was looking for, so I asked here. – KaliMa Apr 19 '16 at 18:20
- 
                    1Possible duplicate of [Android Fragments and animation](http://stackoverflow.com/questions/4817900/android-fragments-and-animation) – Rohit Arya Apr 19 '16 at 18:26
1 Answers
0
            If by view container you mean ViewGroup you can use a ValueAnimator. It's a simple timing engine that you can use to do animation.
For example if you want to animate a change of height for a RelativeLayout rl to finalHeight from startHeight in 400ms you can do :
ValueAnimator va = ValueAnimator.ofFloat(0f, 1f);
va.setDuration(400);
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            public void onAnimationUpdate(ValueAnimator animation) {
                Float value = (Float) animation.getAnimatedValue();
                rl.height = (int) (startHeight + (finalHeight - startHeight) * value);
                rl.requestLayout();
            }
        });
You can use different interpolator and customize the ValueAnimator to do some really nice effect. http://developer.android.com/reference/android/animation/ValueAnimator.html
 
    
    
        Gauthier
        
- 4,798
- 5
- 34
- 44
