Android: animateLayoutChanges will not work in parent layout

Suppose I have a layout file structured as follows:

<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 insertionPoint layout, and I would like the animation of the elements below (in this case header2 ) to slide down.

Using android:animateLayoutChanges only animates the elements in the insertionPoint layout, 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 animations that we can see in the People app in ICS when we add more fields to the contact, such as phone numbers.

Thanks!

+6
source share
1 answer

API 16 added the LayoutTransition.CHANGING animation LayoutTransition.CHANGING , but it is disabled by default.

To turn on:

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

Good DevBytes video: https://www.youtube.com/watch?v=55wLsaWpQ4g

+2
source

Source: https://habr.com/ru/post/921637/


All Articles