0

This question refers to the Transitions API. I am using TransitionManager.beginDelayedTransition. As I have several views changing position, I wanted to teleport some of them, because moving them doesn't look good. By teleporting I mean, making them disappear animatedly, and then reappear in the new position, also animatedly. I have overriden Visibility to modify how views appear or disappear, but I don't know how to override ChangeBounds (or any other class, if more appropriate) to make the view disappear and reappear instead of move.

This code is an attempt I have done, but it does nothing to the view.

@Override
    public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
        PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat("scaleX", 1, 0);
        PropertyValuesHolder holderY = PropertyValuesHolder.ofFloat("scaleY", 1, 0);
        ValueAnimator disappear = ObjectAnimator.ofPropertyValuesHolder(holderX, holderY);
        holderX = PropertyValuesHolder.ofFloat("scaleX", 0, 1);
        holderY = PropertyValuesHolder.ofFloat("scaleY", 1, 1);
        ValueAnimator appear = ObjectAnimator.ofPropertyValuesHolder(holderX, holderY);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playSequentially(disappear, appear);

        return animatorSet;
    }

Returning appear, or disappear has the same result: nothing.

4

1 回答 1

0

您快到了。您只需要使用淡出删除视图,然后将其添加回新位置并作为两个单独的事务淡入(因为这正是您要求发生的事情)。

于 2015-04-07T19:08:50.280 回答