1

I am using a simple ObjectAnimator to animate a custom view along x and y coordinates using the code below. For some reason after the animation is complete, the view is not rendered completely. Parts of it are missing. Once I click on the view, it resets and looks complete. I have tried invalidating the custom view using invalidate() and requestLayout() in the onAnimationEnd(), but that does not help. Any ideas?

private void animateToNewPosition(final PointF coordinates) {

    final android.animation.AnimatorSet animSetXY = new android.animation.AnimatorSet();
    animSetXY.setInterpolator(new AccelerateDecelerateInterpolator());
    animSetXY.setDuration(250);

    ObjectAnimator xAnimator = ObjectAnimator.ofFloat(container, "x", coordinates.x);
    ObjectAnimator yAnimator = ObjectAnimator.ofFloat(container, "y", coordinates.y);
    animSetXY.playTogether(xAnimator, yAnimator);
    animSetXY.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animator) {

        }

        @Override
        public void onAnimationEnd(Animator animator) {
        }

        @Override
        public void onAnimationCancel(Animator animator) {

        }

        @Override
        public void onAnimationRepeat(Animator animator) {

        }
    });
    animSetXY.start();
}
user1689757
  • 475
  • 5
  • 19

0 Answers0