I'm trying to do an easy translation animation in Android. The following doesn't work:
public class MyView extends ViewGroup {
...
TranslateAnimation animation = new TranslateAnimation(0, 0, 0, -500);
animation.setDuration(300);
startAnimation(animation);
...
}
However, this works:
public class MyView extends ViewGroup {
...
animate().setDuration(300).translationYBy(-500);
...
}
I need the top version to work because I'm adding in more views that need to be animated at the same time and I'd like to use TranslateAnimation
s inside an AnimationSet
.