本文介绍了Android设置缩放动画的枢轴点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将视图缩放到特定大小,但不太了解旋转的工作原理.

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

假设我只想向上缩放视图.pivotY"应该保持什么价值?在 XML 中,它是一个百分比.以编程方式应用枢轴点的情况如何?

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?

例子:

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

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

推荐答案

其实很简单.

如果您想向上扩展,一个明确的选择是:

If you want to scale upwards one clear option is:

 view.setPivotY(100);

以下:

 view.setPivotY(0);

然后制作动画.

这篇关于Android设置缩放动画的枢轴点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-12 12:12