android objectanimator scaleX仅在一个方向上

kor*_*.es 6 android objectanimator

我正在使用ObjectAnimator并且无法弄清楚如何仅在一个方向上向x轴缩放,例如向右侧.因为当我缩放它时,它可以两种方式缩放,然后我的ImageView不在屏幕上.我知道我可以添加transitionX以防止离开屏幕,但更好的解决方案是在一个方向上缩放.

ObjectAnimator headAnim = ObjectAnimator.ofFloat(imageHead, "scaleX", 1f, 1.5f);
    headAnim.setDuration(1000);
    headAnim.start();
Run Code Online (Sandbox Code Playgroud)

Rom*_*Guy 18

只需使用View.setPivotX()和设置视图的轴心点即可View.setPivotY().将其设置为0,0以达到您想要的效果.