I'm trying out an official example on LayoutTransition.
I've modified it in order to have 2 containers. I add new items to 1'st (top) container with animation and the 2'nd (bottom) container moves down with slide animation, as expected.
But when I remove item from 1'st container, the whole 2'nd container goes beneath 1'st container, while 1'st container is shrinking height with animation (while animation is playing last element of 1'st and first element of 2'nd are intersecting).
Is there any way to make 2'nd container slide up while 1'st container is shrinking?
layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff">
<ScrollView android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:id="@+id/container1"
android:background="@drawable/border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:showDividers="middle"
android:divider="?android:dividerHorizontal"
android:animateLayoutChanges="true"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
</ScrollView>
<ScrollView
android:layout_width="match_parent" android:layout_height="wrap_content">
<LinearLayout android:id="@+id/container2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:showDividers="middle"
android:divider="?android:dividerHorizontal"
android:animateLayoutChanges="true"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
</ScrollView>
</RelativeLayout>
This may not be the correct answer and it's definitely too late for this answer but it might be helpful and I had a similar issue where one item was disappearing and I wanted the second item to expand while the item was disappearing. I used
setStartDelay()
of LayoutTransition in code for bothLayoutTransition.CHANGE_DISAPPEARING
andLayoutTransition.DISAPPEARING
to 0, as well assetDuration()
of both to the same value. You might have to mess with those values forLayoutTransition.CHANGING
, since that affects expanding views, but honestlyLayoutTransition
may not be capable of it (though I definitely don't know for sure), because while the expanding view is DEFINITELYCHANGING
, the second item moving up is probably notCHANGE_DISAPPEARING
, though you want a similar animation.my code: