Q:

Slide up/down layout on click

I am looking to slide/up down a nested layout on its parent layout click.
Ie the parent layout will have a hidden child.  On click I would like the parents height to animate down (slide down) to fit the child layout.  On click again I would like the child to animate up (slide up).  Basically just animating the parents height to show/hide the child.
I have found this which looks to work but seems like a lot of code:
http://gmariotti.blogspot.com/2013/09/expand-and-collapse-animation.html
I have seen a lot of things using 'animateLayoutChanges' to animate things however I cannot get that to work.
I have tried this:
<LinearLayout android:id="@+id/parent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <LinearLayout android:id="@+id/child"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        android:animateLayoutChanges="true">

        <TextView android:id="@+id/message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Some text to show/hide"/>
    </LinearLayout>

</LinearLayout>

Then in code:
    LinearLayout parent = (LinearLayout)findViewById(R.id.parent);
    parent.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
           LinearLayout child = (LinearLayout)findViewById(R.id.child);
           child.setVisibility(child.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
        }
    });

That sets the visibility of the child view correctly but there is absolutely no animation.

A:

Well, first of all android:animateLayoutChanges effects the child elements. So, obviously, if you are changing the properties of the element itself, it will not be animated.
I think you can accomplish what you are trying to in API 16 by enabling the LayoutTransition.CHANGING animation.
<LinearLayout android:id="@+id/parent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:animateLayoutChanges="true">
    <TextView android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Title"/>
    <TextView android:id="@+id/message"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:text="Some text to show/hide"/>
</LinearLayout>

LinearLayout parent = (LinearLayout)findViewById(R.id.parent);
parent.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);

View text = findViewById(R.id.text);
text.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        View message = findViewById(R.id.message);
        ViewGroup.LayoutParams params = message.getLayoutParams();

        params.height = params.height == 0 ? ViewGroup.LayoutParams.WRAP_CONTENT : 0;

        message.setLayoutParams(params);
    }
});

