Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e115ffeb authored by Chet Haase's avatar Chet Haase
Browse files

Fix behavior of custom animations for LayoutTransition.

Previously, setting custom animations on a LayoutTransition would cause
those animations to be run not only for changing views in the container, but
for the parent hierarchy of those views as well. This can lead to unexpected
behavior, as seen in the ApiDemos LayoutAnimations and LayoutAnimationsHideShow.
This change changes the behavior so that the parent hierarchy is animated by
the default animations (which change the bounds and scrollX/Y fields) instead
of custom animations.

Change-Id: I9a04d97fabbc34dc0d5809eb3fd8ac08e0801d7c
parent 5e3f4000
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -593,11 +593,13 @@ public class LayoutTransition {
            }
        }
        if (mAnimateParentHierarchy) {
            Animator parentAnimator = (changeReason == APPEARING) ?
                    defaultChangeIn : defaultChangeOut;
            ViewGroup tempParent = parent;
            while (tempParent != null) {
                ViewParent parentParent = tempParent.getParent();
                if (parentParent instanceof ViewGroup) {
                    setupChangeAnimation((ViewGroup)parentParent, changeReason, baseAnimator,
                    setupChangeAnimation((ViewGroup)parentParent, changeReason, parentAnimator,
                            duration, tempParent);
                    tempParent = (ViewGroup) parentParent;
                } else {
@@ -626,12 +628,18 @@ public class LayoutTransition {

    /**
     * This flag controls whether CHANGE_APPEARING or CHANGE_DISAPPEARING animations will
     * cause the same changing animation to be run on the parent hierarchy as well. This allows
     * cause the default changing animation to be run on the parent hierarchy as well. This allows
     * containers of transitioning views to also transition, which may be necessary in situations
     * where the containers bounds change between the before/after states and may clip their
     * children during the transition animations. For example, layouts with wrap_content will
     * adjust their bounds according to the dimensions of their children.
     *
     * <p>The default changing transitions animate the bounds and scroll positions of the
     * target views. These are the animations that will run on the parent hierarchy, not
     * the custom animations that happen to be set on the transition. This allows custom
     * behavior for the children of the transitioning container, but uses standard behavior
     * of resizing/rescrolling on any changing parents.
     *
     * @param animateParentHierarchy A boolean value indicating whether the parents of
     * transitioning views should also be animated during the transition. Default value is true.
     */