Android setting pivot point for scale animation

我与影子孤独终老i 提交于 2020-01-12 12:24:13

问题


I am trying to scale views to a certain size but can't quite understand how pivoting works.

Say I want to scale the view upwards only. What value should the "pivotY" hold? In XML, it is a percentage. How is it when applying pivot point programmatically?

Example:

ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", scaleSize);
ObjectAnimator pivotY = ObjectAnimator.ofFloat(view, "pivotY", pivotPoint);

AnimatorSet set = new AnimatorSet();
set.PlayTogether(scaleY, pivotY);

回答1:


Quite simple actually.

If you want to scale upwards one clear option is:

 view.setPivotY(100);

and downwards:

 view.setPivotY(0);

then animate.




回答2:


Use:

view.setPivotY(view.getMeasuredHeight());

If you need to animate your object from the bottom.



来源:https://stackoverflow.com/questions/17031931/android-setting-pivot-point-for-scale-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!