title: Animation of height of LinearLayout container with ValueAnimator
body: <p>I have a LinearLayout that I use as a container for some buttons and textview's that I would like to animate the height of to give an impression of the layout sliding down when the user presses a "show" button.</p>
  
  <p>I have set the LinearLayout to layout_height="0dp" and visibility="gone" in my xml. I then wish to set it to be visible and whatever height is need to wrap the content. At the moment I'm having issues even animating it at all, nevermind the wrap content height.</p>
  
  <p>Here's my method for animating:</p>
  
  <pre><code>private void toggle(final LinearLayout v) {
      v.setVisibility(View.VISIBLE);
      ValueAnimator va = ValueAnimator.ofInt(0, 300);
      va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
          public void onAnimationUpdate(ValueAnimator animation) {
              Integer value = (Integer) animation.getAnimatedValue();
              v.getLayoutParams().height = value.intValue();
              v.invalidate();
  
          }
      });
  
      va.start();
  }
  </code></pre>
  
  <p>Perhaps the problem is how I am setting the height of the LinearLayout? Or am I misunderstanding the function of the ValueAnimator? I've looked around at the blog post's by Chet Haase but they do not contain any specific height animation examples. Neither have I been able to find and good examples of how to work with animations of height using API's from 3.0+. Would love some help on this, thanks!</p>