Adjust layouts of transition demos to improve fade-outs.

When a container's child count goes to zero, it may report a measurement size
of zero. This affects LayoutTransition's fading-out of target views
because they may get clipped out by a layout that got sized to 0 because it
thinks it has no children. The workaround is to tell the layout to size itself
either with some minimal size (in the case of the FixedGridLayout used by some
demos) or with match_parent in some cases to ensure that the layout always has
some nonzero size.

Change-Id: I908e64d4fb054928af277a021a328e94477c9c83
diff --git a/samples/ApiDemos/res/layout/layout_animations_by_default.xml b/samples/ApiDemos/res/layout/layout_animations_by_default.xml
index b7f69ab..a5062bb 100644
--- a/samples/ApiDemos/res/layout/layout_animations_by_default.xml
+++ b/samples/ApiDemos/res/layout/layout_animations_by_default.xml
@@ -16,7 +16,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
+    android:layout_height="match_parent"
     >
     <Button
         android:layout_width="wrap_content"
@@ -27,7 +27,7 @@
     <LinearLayout
         android:orientation="horizontal"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
+        android:layout_height="wrap_content"
         android:id="@+id/horizontalContainer"
         android:animateLayoutChanges="true"
         />
diff --git a/samples/ApiDemos/res/layout/layout_animations_hideshow.xml b/samples/ApiDemos/res/layout/layout_animations_hideshow.xml
index 641f6c1..4215ac1 100644
--- a/samples/ApiDemos/res/layout/layout_animations_hideshow.xml
+++ b/samples/ApiDemos/res/layout/layout_animations_hideshow.xml
@@ -16,13 +16,13 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
+    android:layout_height="match_parent"
     android:id="@+id/parent"
     >
     <LinearLayout
         android:orientation="horizontal"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
+        android:layout_height="wrap_content"
         >
         <Button
             android:layout_width="wrap_content"
diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/FixedGridLayout.java b/samples/ApiDemos/src/com/example/android/apis/animation/FixedGridLayout.java
index 75c5580..5d92e85 100644
--- a/samples/ApiDemos/src/com/example/android/apis/animation/FixedGridLayout.java
+++ b/samples/ApiDemos/src/com/example/android/apis/animation/FixedGridLayout.java
@@ -64,9 +64,11 @@
             final View child = getChildAt(index);
             child.measure(cellWidthSpec, cellHeightSpec);
         }
-        // Use the size our parents gave us
-        setMeasuredDimension(resolveSize(mCellWidth*count, widthMeasureSpec),
-                resolveSize(mCellHeight*count, heightMeasureSpec));
+        // Use the size our parents gave us, but default to a minimum size to avoid
+        // clipping transitioning children
+        int minCount =  count > 3 ? count : 3;
+        setMeasuredDimension(resolveSize(mCellWidth * minCount, widthMeasureSpec),
+                resolveSize(mCellHeight * minCount, heightMeasureSpec));
     }
 
     @Override
diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimations.java b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimations.java
index 5d38b03..65ad782 100644
--- a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimations.java
+++ b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimations.java
@@ -58,6 +58,7 @@
         setContentView(R.layout.layout_animations);
 
         container = new FixedGridLayout(this);
+        container.setClipChildren(false);
         ((FixedGridLayout)container).setCellHeight(50);
         ((FixedGridLayout)container).setCellWidth(200);
         final LayoutTransition transitioner = new LayoutTransition();
@@ -77,6 +78,7 @@
 
         ViewGroup parent = (ViewGroup) findViewById(R.id.parent);
         parent.addView(container);
+        parent.setClipChildren(false);
         Button addButton = (Button) findViewById(R.id.addNewButton);
         addButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsHideShow.java b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsHideShow.java
index 66e424e..3ee7b0c 100644
--- a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsHideShow.java
+++ b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsHideShow.java
@@ -53,10 +53,9 @@
 
         final CheckBox hideGoneCB = (CheckBox) findViewById(R.id.hideGoneCB);
 
-        container = new FixedGridLayout(this);
-        ((FixedGridLayout)container).setCellHeight(50);
-        ((FixedGridLayout)container).setCellWidth(100);
         container = new LinearLayout(this);
+        container.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
+                ViewGroup.LayoutParams.MATCH_PARENT));
 
         // Add a slew of buttons to the container. We won't add any more buttons at runtime, but
         // will just show/hide the buttons we've already created