0

Whenever I use TranslateAnimation to move an object to a new location, for some reason, the touch target of that object remains in the old position.

How do I change this behaviour?

eg.

public static void hideViewUp (View v, int duration) {

            AnimationSet animSet = new AnimationSet(true);
            animSet.setFillAfter(true);
            animSet.setDuration(duration);
            AlphaAnimation alp = new AlphaAnimation(1.0f, 0);
            TranslateAnimation translate = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
                    Animation.RELATIVE_TO_SELF,
                    Animation.RELATIVE_TO_SELF,
                    -(v.getTop() + v.getHeight()));
            animSet.addAnimation(translate);
            animSet.addAnimation(alp);
            v.startAnimation(animSet);

    }
Shubham Kanodia
  • 6,036
  • 3
  • 32
  • 46

1 Answers1

0

There's no need to post any sample code - the issue is indeed pretty well known and general.

TranslateAnimation and all other old types of animation change only the draw transformation matrix. These animations shouldn't be used to move items permamently.

To truly move a view to a new position, use ObjectAnimator.

Here's an example: http://www.android-app-market.com/animations-in-android-translate-animation-alpha-animation-object-animation.html

Zielony
  • 16,239
  • 6
  • 34
  • 39