Android objectanimator scaleX in one direction only

I am using ObjectAnimator and cannot figure out how to scale in x ax in only one direction, for example, on the right side. Because when im scales, it scales in both directions, and then my ImageView doesn't work. I know that I can add transition X to prevent the screen from exiting, but the best solution will scale in one direction.

ObjectAnimator headAnim = ObjectAnimator.ofFloat(imageHead, "scaleX", 1f, 1.5f); headAnim.setDuration(1000); headAnim.start(); 
+4
source share
2 answers

Just set the view reference point using View.setPivotX() and View.setPivotY() . Set it to 0.0 to achieve the desired effect.

+16
source

and you should know that: The View.setPivotX / Y parameter is the value of the float. but this is the absolute value of the width or height, not percent.

+1
source

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


All Articles