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.

lotdrops
  • 300
  • 5
  • 16

1 Answers1

0

You're almost there. You'll simply need to remove the view with a fade-out and then add it back in it's new location with a fade-in as two separate transactions (because that's precisely what you're asking to have happen).

  • I don't understand what do you mean with two separate transactions. If I extend change bounds, it is called only once, because of the view's movement (that's why I tried using animatorSet). And I also tried setting the view to INVISIBLE before moving and to VISIBLE afterwards, using the fade animation, but the animations are not played. – lotdrops Apr 08 '15 at 22:06