<ViewFlipper
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:measureAllChildren="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
</RelativeLayout>
</ViewFlipper>
I have view flipper. And animation with changing that views working fine:
Animation slideDown = AnimationUtils.loadAnimation(getActivity(), android.R.anim.slide_in_left);
slideDown.setDuration(900);
Animation slideUp = AnimationUtils.loadAnimation(getActivity(), android.R.anim.slide_out_right);
slideUp.setDuration(300);
mReceiverFlipper.setInAnimation(slideDown);
mReceiverFlipper.setOutAnimation(slideUp);
My problem is I can't animate my flipperView vertically. Since two child views have different height. And when I am flipping between childViews my fipperView resizing his height without animation.
So, how can I animate flipperView when his size is changing?
You can use the
android:animateLayoutChangesattribute.Add the attribute
android:animateLayoutChangeson the ViewFlipper and set it to true. (<ViewFlipper android:animateLayoutChanges="true" ...)Then in your code, you need to add this line to enable the animation:
or in Kotlin:
Source: https://proandroiddev.com/the-little-secret-of-android-animatelayoutchanges-e4caab2fddec