Suppose I have a layout file structured like this:
<LinearLayout android:id="@+id/main" android:orientation="vertical" android:animateLayoutChanges="true">
<EditText>
<TextView android:id="@+id/header1">
<LinearLayout android:id="@+id/insertionPoint" android:orientation="vertical" android:animateLayoutChanges="true">
</LinearLayout>
<TextView android:id="@+id/header2">
</LinearLayout>
I want to dynamically add text fields to the Layout insertionPoint
and I would like to see an animation of the elements below it (in this case, header2
) sliding down.
Using android:animateLayoutChanges
only animates the elements in the layout insertionPoint
, so there is no animation for header2
. What should I do?
Just to be more clear: what I would like to do here is something like the animations that we can see in the People app in ICS when we add more fields, like telephone numbers, to a contact.
Thank you!
API 16 added the LayoutTransition.CHANGING
animation type, however it is disabled by default.
To enable:
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.main);
linearLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
Nice DevBytes video: https://www.youtube.com/watch?v=55wLsaWpQ4g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With