ZakTaccardi ZakTaccardi - 1 month ago 5
Android Question

Is android:animateLayoutChanges supposed to work when a child view's height is updated?

http://developer.android.com/training/animation/layout.html

<LinearLayout
animateLayoutChanges="true">
<View1/>
<View2/>
<View3/>
</LinearLayout>


Let's say
View2
's height increases at runtime. I would expect
View3
to animate downward. Instead, it snaps directly into its new position.

Why does my desired animation not occur?

Answer

According to https://developer.android.com/reference/android/animation/LayoutTransition.html

By default, all transition types except CHANGING are enabled.

So if you want to animate when a child changes its size. You can do so by

LayoutTransition layoutTransition = new LayoutTransition();
layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
parentView.setLayoutTransition(layoutTransition);