Android animation moves your eyes to another view

I have two views in different layouts. I want to move one to another. What happened to my code? Y animation does not play correctly. The first view is located in the fragment layout, the second in the status bar

... int p1[] = new int[2]; int p2[] = new int[2]; viewOne.getLocationInWindow(p1); viewTwo.getLocationInWindow(p2); AnimatorSet animatorSet = new AnimatorSet(); animatorSet .play(ObjectAnimator.ofFloat(expandedImageView, "X", p1[0], p2[0] - p1[0])) .with(ObjectAnimator.ofFloat(expandedImageView, "Y", p1[1], p2[1] - p1[1])) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale)); 
+5
source share
1 answer

I have another solution for you: (moving viewOne to viewTwo)

  TranslateAnimation animation = new TranslateAnimation(0, viewTwo.getX()-viewOne.getX(),0 , viewTwo.getY()-viewOne.getY()); animation.setRepeatMode(0); animation.setDuration(3000); animation.setFillAfter(true); viewOne.startAnimation(animation); 
+15
source

Source: https://habr.com/ru/post/1208145/


All Articles