I have a TextView inside a LinearLayout. My goal is to animate the TextView height change when its text changes and need more or less lines.

I split the work this way :

1. Fade out the old text
2. Animate the TextView new height (and the parent LinearLayout)
3. Fade in the new text

The fade in / fade out part is easy, but I struggle for the height change animation.

Here's my simplified layout :

```
<LinearLayout
    android:id="@+id/fragment_tooltip_tooltip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/tooltip_blue_bg"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/fragment_tooltip_message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />
</LinearLayout>

```

And here is what I tried :

```
    final int currentHeight = tvMessage.getHeight();

    tvMessage.setText(toTooltip.getMessage());

    tvMessage.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            TooltipFragment.this.tvMessage.getViewTreeObserver().removeGlobalOnLayoutListener(this);

            final int newHeight = tvMessage.getHeight();

            ResizeAnimation resizeAnimation = new ResizeAnimation(tvMessage, tvMessage.getWidth(), tvMessage.getWidth(),
                    currentHeight, newHeight);
            resizeAnimation.setDuration(ANIM_DURATION_TRANSITION_TEXT_RESIZE);
            resizeAnimation.setInterpolator(new FastOutSlowInInterpolator());
            resizeAnimation.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                    // No-op
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    // Finally we show the new content
                    ...
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                    // No-op
                }
            });
            tvMessage.startAnimation(resizeAnimation);
        }
    });

```

The problem with this solution is that the tvMessage.setText(toTooltip.getMessage()); line used to measure the new height expand immediately the TextView and LinearLayout, then the animation resize the view to its previous size before applying the resize the animation, producing an ugly visual effect.

I believe a TextSwitcher will not animate the height change and so is not a solution, but I didn't tried it.