android objectanimator scaleX only in one direction
Asked Answered
I

2

7

I am using ObjectAnimator and cant figure out how to scale in x axe only in one direction for example to right side. Because when im scaling it scales both ways and then my ImageView is out of screen. I know i could add transitionX to prevent going off-screen but a better solution would be scaling in one direction.

ObjectAnimator headAnim = ObjectAnimator.ofFloat(imageHead, "scaleX", 1f, 1.5f);
    headAnim.setDuration(1000);
    headAnim.start();
Insolence answered 16/8, 2013 at 22:44 Comment(0)
A
20

Just set the pivot point of the View, using View.setPivotX() and View.setPivotY(). Set it to 0,0 to achieve the effect you want.

Aparejo answered 16/8, 2013 at 22:52 Comment(0)
A
2

The param of View.setPivotX/Y is a float value. It is the absolute value of width or height, not the percent.

Arthralgia answered 19/6, 2015 at 2:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.